Posts

Showing posts from August, 2013

How can I enable HTTP/2 on HAProxy? -

Image
we have shifted http https. have moved https, thinking of moving http/2 performance benefits. as explained above requests between browser , lb secured (https) while communication between lb , app server still using http what possibility of enabling http /2 current setup? can enable http/2 between browser , lb while communication between lb , app servers remain on http? haproxy doesn't support http/2 yet. in may 2015 haproxy page mentioned http/2 support coming in 1.7 , hasn't happened. recent update haproxy november 2016 : will http/2 on roadmap of 1.8 or 2.0? yes definitely. know community-driven project cannot have roadmap, hints contributors. bottleneck because while review , integrate code cannot develop. thought have h2 in 1.6 if remember :-) so let's we'll put lot of efforts getting h2 in 1.8. count lot on spop move contribs outside of core , release of time :-) the person writing willy tarreu, cto , lead softwa

scala - Spark saveAsTextFIle goes in endless loop -

i'm running spark in stand-alone mode on single machine. have rdd name of productuservectors , this [("11342",map(..)),("21435",map(..)),...] the number of rows in normalisedvectors 8164. wanted possible pair combinations between rows of rdd , compute score based on maps in each row. used cartesian possible pairs, , i'm filtering them shown below scala> val normalisedvectors = productuservector.map(line=>utilinst.normalisevector(line)).sortby(_._1.toint) scala> val combinedrdd = normalisedvectors.cartesian(normalisedvectors).filter(line=>line._1._1.toint > line._2._1.toint && utilinst.filterstyleatp(line._1._1,line._2._1)) scala> val scoresrdd = combinedrdd.map(line=>utilinst.getscore(line)).filter(line=>line._3 > 0) scala> val finalrdd = scoresrdd.map(line=> (line._1,list((line._2,line._3)))).reducebykey(_ ++ _) scala> finalrdd.saveastextfile(outputpath) i have set driver memory @ 8gb , executor memo

sbt - Akka cluster for Scala 2.10 - cluster events -

i'm using akka cluster , want listen on event of memberjoined , memberleft: override def prestart(): unit = { cluster.subscribe(self, classof[memberevent], classof[memberjoined], classof[memberleft]) } the problem requires following dependency: "com.typesafe.akka" % "akka-cluster_2.11.xx" % "2.4.12" but have use scala 2.10 (i can't change 2.11) , akka api scala 2.10 2 events missing: akka api scala 2.10 (exists on akka api scala 2.11 ) is there other way can listen on events? override def receive = { case memberjoined(member) => println(s"member joined $member") case memberleft(member) => println(s"member left $member") } the difference not between scala versions, between akka versions. akka 2.4.x not compatible scala 2.10, akka 2.3.x compiled against scala 2.10. as far i'm aware, changes of clustering implementation done in 2.4.x , not back-ported 2.3.x version.

sql server 2008 - calculate difference and percentage -

i have following data , numbers recruited/applied particular office, , find difference between previous , current year , percentage increase or decrease. mentioned formulas use in brackets in expected output. office year recruited applied pune 2015 10 15 pune 2016 7 20 mumbai 2015 10 23 mumbai 2016 15 18 my expected output should like: office difference %recruited pune -3 (7-10) -30%(7-10/10) mumbai 5(15-10) 50% please help. if using sql server 2012 or higher use lag (or lead) function. since aren't can creative cte. approach taken http://blog.sqlauthority.com/2013/09/22/sql-server-how-to-access-the-previous-row-and-next-row-value-in-select-statement/ . select 'pune' office, '2015' year, 10 recruited, 15 applied #temp union select 'pune' office, '2016' year, 7

javascript - Target element of array for collision detection -

update: wanted let know i'd solved problem, if not answered own question. rather trying target element of push array, did this: in var ground=[], water=[], enemies=[], environment=[]; i added tokens=[]; to end. then wrote new function, updatetokens: function updatetokens() { (var = 0; < tokens.length; i++) { tokens[i].update(); tokens[i].draw(); if (player.mindist(tokens[i]) <= player.width - platformwidth/2) { gameover(); } } if (tokens[0] && tokens[0].x <- platformwidth) { tokens.splice(0, 1); } } (the 'gameover();' function testing purposes). added 'spawntokenssprites();' spawnsprites(); function. next, wrote new function spawntokenssprites: function spawntokenssprites() { if (score > 0 && rand(0,20) === 0 && platformheight < 3 { if (math.random() > 0.5) { tokens.push(new sprite( canvas.width + platformwidth % player.speed, platformbase - platformheight * platf

ruby - undefined method `model_name' with simple_form on Rails 5 -

i'm getting undefined method 'model_name' error simple_form when want edit basic post on rails 5. show.html.haml: = link_to "edit", edit_post_path(@post) edit.html.haml: = simple_form_for @post |f| = f.input :title = f.input :link = f.input :description = f.button :submit posts_controller.rb: def show @post = post.find(params[:id]) end def edit end def update if @post.update(post_params) redirect_to @post else render 'edit' end end any idea? def edit @post = post.find(params[:id]) # <========= end

dictionary - C# - Code not running and I can't figure out why -

i'm creating discord bot using discord.net, don't think matters here, , i'm trying checks dictionaries , i've run problem code doesn't run , can figure out why. let me try , summarize code. private dictionary<server, dictionary<user, chatterbotsession>> sessions = new dictionary<server, dictionary<user, chatterbotsession>>(); if (sessions.any()) { if (sessions[e.server].any()) { await e.channel.sendmessage("sorry, i'm talking on server.").configureawait(false); return; } } chatterbotfactory factory = new chatterbotfactory(); chatterbot.chatterbot bot = factory.create(); chatterbotsession session = bot.createsession(); dictionary<user, chatterbotsession> sessiondic = new dictionary<user, chatterbotsession>(); sessiondic.add(e.user, session); sessions.add(e.server, sessiondic); await e.channel.sendmessage("added dicionary entry server '" + e.server.name + "'

angularjs - GET and POST calls fail to load resource -

in ionic application, every $http post or get call gets blocked: failed load resource: net::err_name_not_resolved it works fine in ipv4 shows error when select ipv6 in apns settings in our phone networks. how should continue? config.xml file <?xml version="1.0" encoding="utf-8" standalone="yes"?> <widget id="com.jio.smart.vehicle" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>name</name> <description>&#xd;&#xd; ionic framework , cordova project.&#xd;&#xd; </description> <author email="hi@ionicframework" href="http://ionicframework.com/">&#xd;&#xd; ionic framework team&#xd;&#xd; </author> <content src="index.html"/> <access origin="*" subdom

javascript - Google charts json error -

i trying create google char using json object. keep getting error when running var data = new google.visualization.datatable(chartdata); please see code below, appreciated. var addresses = json.parse('{"with address": 45532627,"without address": 10845793}'); var age = json.parse('{"18-25": 2162586,"26-35": 9995883,"36-45": 9486158,"46-55": 8729677,"56-65": 6913371,"65+": 10545270}'); var cellphone = json.parse('{"with cellphone": 21536203,"without cellphone": 34842217}'); google.charts.load("current", {packages:["corechart"]}); google.charts.setonloadcallback(drawchart(addresses,'addresses')); google.charts.setonloadcallback(drawchart(age,'age')); google.charts.setonloadcallback(drawchart(cellphone,'cellphone')); function drawchart(chartdata,name) {

Place cursor handler at the end of selection programmatically in Android EditText -

i trying select particular word programmatically in android edittext. used setselection(start,end) did select word failed retain left , right cursor handler. after selecting word can't able extend selection since there no cursor handler available. my requirement should able extend selection after selecting word using setselection() . (like default double-click behaviour on edittext, selects word , retains cursor handlers). is there method available place cursor handlers @ end of selection after selecting particular word using setselection() ? thanks in advance.

Modify a dictionary in a for loop in C# -

i experienced in c/c++ pretty newbie in c#. question pretty simple. have hash table integer keys , values , want increment values in hash table 1. prefer accomplish o(1) memory. below 1 solution, which, opinion, somehow ugly. there other way make looks more decent? dictionary<int, int> dict = new dictionary<int, int>(); (int = 0; < dict.count; ++i) { dict[dict.keys.elementat(i)]++; } ps: heard foreach read-only in c#. but, there way for(auto it& : dict) it.second++ in c++ can use still accomplish task in c#? dictionary<,> doesn't provide way of doing - because updating value associated key counts change invalidates iterator. concurrentdictionary<,> does allow though, , has addorupdate method you: using system; using system.linq; using system.collections.concurrent; class test { static void main() { var dict = new concurrentdictionary<int, int> {

linux - formatting output of booleans c++ -

i begginner @ programming in c++ , know if there way can change output of boolean variables low level graphics in terminal (linux). display example small circle true , small square false . i needing display array of booleans in terms of small symbols such example above output project, suggestions on best way impliment function if have asked not possible? you can print unicode symbols using std::wcout . e.g. "\u2605" print star. so can write like std::wcout<< (mybool) ? "\u2605" : "\u25cf" <<std::endl; this print star if mybool true or circle if false you can find many tables of unicode characters online, e.g. here: http://jrgraphix.net/r/unicode/

gnuplot - How to add points at intervals -

Image
i add points graph @ every 100 interval shown in graph. have used line in gnuplot, error "every" unrecognized token. using gnuplot v5. how can add point @ interval of 100 in graph? set xtics 100 set yrange [ 0 : 3000 ] noreverse nowriteback plot [x=100:1000] x every 100 every can used data files, not functions. simplest solution set number of samples: set xrange [100:1000] set samples 10 plot x points

how to get a path variable value in servlet -

i want path variable in servlet. assume url www.demo.com/123/demo . want 123 value path without doing string manipulation operation. note: following servlet doesn't have web.xml configurations. code is: @webservlet(urlpatterns = { "/demo" }) public class demoservlet extends httpservlet { public demoservlet() { super(); } protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { dopost(request,response); } protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { sysout("demo"); } } the portion of url referring "context". use request.getcontextpath() this. in case of example, return /123 . if want exactly 123 have remove leading slash. from documentation : returns portion of request uri indicates context of request. context path comes first in r

azure - B2B with Microsoft Graph -

as know, creating multi-tenant azure application, using b2b functionallity. i testing b2b functionality , after research got working sample. small summary: user authenticates against common authority, first token acquired via common authority authorization code , then, everytime need service client, try obtain tokens 'current tenants' authority. when request 'me', works against home tenant. when request me trusted tenant, got error user identifier not exist in directory. because user not exist in trusted tenant. when request users, works fine. can both, home tenant users , trusted tenant users. is normal behaviour? need handle programmatically or been solved using ad graph? (so when know need user info, query home tenant?) or bug? any thoughts on appreciated! guests added directory via b2b collaboration feature not work correctly on multi-tenant apps or microsoft graph if you're using common endpoint. the common endpoint authenticate use

Invalid xml:base in Teamcity nuget feed -

Image
i try setup teamcity nuget feed. when try download package form nuget server next error in vs output window: when try definition of nuget feed see next: in administration / global settings / server url have valid dmin name of server. how can change xml:base attribute in feed definition? i don't think there issue teamcity. can see hosting teamcity locally on development machine , downloading own packages (1st picture). error seeing in chrome absolutely fine. however issue appears having have not configured either visualstudio or solution in visualstudio download more 1 place. package failing nancyfx presumably not hosting teamcity therefore need go , public nuget server. in order achieve either have configure visualstudio or solution file search multiple package sources. https://docs.nuget.org/ndocs/tools/package-manager-ui#package-sources

Ionic2 / Cordova error on run android, "t.getNavParams() is not a function" -

i'm trying test app on android device, i've tested in browser , works fine. build completes successfully, , ionic/cordova logs launching successfully, white screen of death on android device. when chrome inspect it, error "t.getnavparams() not function". have no idea begin looking on one.

javascript - After ajax success update input field and fire KeyUp event -

i have input field being dynamically updated ajax function. how fire "keyup" updated input value picked js script. i'm trying mimic user typing number input field. in advance here code have update input field var interval = 500; // 1000 = 1 second, 3000 = 3 seconds function doajax() { $.ajax({ type: 'post', url: 'speed.php', data: $(this).serialize(), datatype: 'json', success: function (data) { $('#kilometers').val(data); }, complete: function (data) { // schedule next settimeout(doajax, interval); } }); } settimeout(doajax, interval); $('#kilometers').keyup(upd

android - How can i improve openCV people detecting algorithm -

i trying write human detector, works now, reacts on cats/boxes etc., got 5 fps. question is, how can improve algorithm better fps , detection accuracy. i have tried use one: http://www.pyimagesearch.com/2015/11/09/pedestrian-detection-opencv/ but couldnt find way use on android. public mat oncameraframe(cvcameraviewframe inputframe) { list<matofpoint> list = new arraylist<>(); mat frame = new mat(); mat gray = new mat(); mat hierarchy = new mat(); mat originalframe = inputframe.rgba(); imgproc.medianblur(originalframe,originalframe,3); imgproc.cvtcolor(originalframe, gray, imgproc.color_rgb2gray, 0); hogdescriptor hog = new hogdescriptor(); //Получаем стандартный определитель людей и устанавливаем его нашему дескриптору matoffloat descriptors = hogdescriptor.getdefaultpeopledetector(); hog.setsvmdetector(descriptors);

System.Linq.Dynamic.Core vs System.Linq.Dynamic -

what difference between system.linq.dynamic.core , system.linq.dynamic? using system.linq.dynamic , not contain support select , selectmany (among other extension methods). system.linq.dynamic.core support these methods? see description on github: system.linq.dynamic system.linq.dynamic.core system.linq.dynamic microsoft assembly .net 4.0 dynamic language functionality. system.linq.dynamic.core .net core port of the microsoft assembly .net 4.0 dynamic language functionality

python 2.7 - Turning my web scrape data into an array -

the following code below pulls information want; however, want sorted array each phone number paired corresponding name, address, , description. can't figure out way indent make pull 38 entries. appreciated! #import libraries selenium import webdriver import csv #driver path driver = webdriver.chrome('c:\python27\chromedriver\chromedriver.exe') #fetch top amsterdam restaurants driver.get('http://www.eater.com/maps/best-amsterdam-restaurants') elem in driver.find_elements_by_xpath('.//h2[span[@class = "c-mapstack__card-index"]]'): restname = elem.text address in driver.find_elements_by_class_name('c-mapstack__address'): restaddress = address.text content in driver.find_elements_by_class_name('c-entry-content'): restdescrip = content.text eaterarray = [restname, restaddress, restdescrip] print eaterarray i aware indenting isn't right, , i've tried several configurations can't seem loop right in configu

tsql - T-SQL import data and remove duplicate records from prior month -

every month receive roster run queries on , generate data gets uploaded table outside source retrieve. question easiest way remove duplicate data prior months upload bearing in mind not data duplicated , if person not appear on new roster prior month needs remain. data time stamped when gets uploaded. thank you you can use cte , row_number() identify , remove dupes ;with cte ( select * ,rn = row_number() on (partition somekeyfield(s) order somedate desc) yourtable ) select * -- << remove if satisfied -- delete -- << remove comment if statisfied cte rn>1 without seeing data structure, take hard partition , order within on clause of row_number()

python - Multiply an integer in a list by a word in the list -

i'm not sure how multiply number following string string. want find rmm of compound started making dictionary of rmms have them added together. issue compounds such h2o. name = input("insert name of molecule/atom find rmm/ram: ") compound = re.sub('([a-z])', r' \1', name) compound = compound.split(' ') r = re.split('(\d+)', compound) for example: when name = h2o compound = ['', 'h2', 'o'] r = ['h', '2', 'o'] i want multiply 2 h making value "['h', 'h', 'o']." tldr: want integers following names in list print listed object 'x' amount of times (e.g. [o, 2] => o o, [c, o, 2] => c o o) the question complicated, let me know if can clarify it. thanks. how following, after define compound : test = re.findall('([a-za-z]+)(\d*)', compound) expand = [a*int(b) if len(b) > 0 else (a, b) in test] match on letters of 1 o

opengl es - Improve texture resolution in GLSL fragment shader -

is there way icrease, or improve resolution of texture using glsl fragment shader processing? let's say, have 512x424 px source image, , want have 1024x848 px result, smooth pixels. update. under "improvement" mean enlarging using sort of resampling algorithm. create fbo, attach large destination texture desired dimensions render "full-screen" textured quad small source texture bound

Make an object of a class from a string in java -

i have different classes, each receives strings , convert different html formats. have chooser class have switch cases divert strings e.g. send strings chooser , stylename this chooser chooser = new chooser(); string text = chooser.format(sometext, stylename); the chooser class this: public string format(string sometext, string stylename) { switch (stylename) { case "newstyle": newstyle ns = new newstyle(); str = ns.refprocess(sometext); break; case "anotherstyle": anotherstyle = new anotherstyle(); str = as.refprocess(sometext); break; case "tet_letters": turk_j_chem tet_letters = new turk_j_chem(); str = tet_letters.refprocess(sometext); break; } } it there short way? when send stylename string , converts class , make object , send sometext class only? i assume have interface: static int

python - Replace unwanted value with the preceding value in the list -

i have following signalid in dataframe( df ). trying smooth signal while replacing unwanted signalid's in following example, a) 6th id 03 should replaced 01 b) 12th , 13th ( 04 , 05 respectively) should replaced 02 01 01 01 01 01 03 01 01 02 02 02 04 05 02 02 02 i can replace value if know exact location, how loop through this? df.id.loc[6] = 01 this code trick... assuming logic determine 3,4,5 invalid > 2. you may need make adjustments logic find value out of place, rest of procedure below should work. find invalid value, set nan. ffill() @ end. import pandas pd import numpy np data = pd.series([51,51,1,51,51,1,1,2,1,1,1,48,48,2,48, 1,1,1,1,3,1,1,2,2,2,4,5,2,2,2]) # answer 2, 7, 13, 19, 25, 26 # size 1 gaps. # next value, data_pr = data.shift(-1) data_nx = data.shift(1) # % exclude first 2 items filder. data_nx[:1]= data[:1] data_pr[-1:] = data[-1:] #data_lag2[:2]= data[:2] # % find idx data != data_lag1 && data ==

adobe brackets - Can i bind my extension to Ctrl-S without disrupting saving? -

i'd make brackets.io extension both save active file , execute code on ctrl-s. i tried use command-line-shortcuts extension throws error /command/keybindingmanager.js:749 cannot assign ctrl-s extension.commandline.run.0. assigned file.save so possible assign 2 'actions' 1 key binding? it seems opened issue on brackets github. can't done.

Maven: Building a sar and adding files -

i building sar archive filetype. using using jboss-packaging-maven-plugin org.codehaus.mojo . however, i'll happy use regular maven-ear-plugin if can need. the sar file i'm building bit strange. libraries kept in root directory (no problem that), there few dozen additional properties files , xml files packed sar. i looking @ documentation of both jboss-packaging-maven-plugin , maven-ear-plugin , don't see way specify additional files in <configuration> section (such <fileset> parameter). switch assembly , build sar way, doesn't assemblies sar formats (at least default). so, how add these additional property files sar either through maven-ear-plugin or jboss-packaging-maven-plugin ? is possible in assembly specify different format other standard formats? if so, how go that? here's pom.xml . <project> <modelversion>4.0.0</modelversion> <parent> <groupid>com.vegicorp</groupid> <art

asp classic - Specify my own message-id header when sending email with cdo.message -

this question has answer here: add header email vb asp 3.0 script 2 answers is there way specifty own message-id cdo ? using following configuration, message-id still generated cdo component , ignores 1 specified. <% const cdosendusingport = 2 dim imsg, iconf, flds set imsg = createobject("cdo.message") set iconf = createobject("cdo.configuration") set flds = iconf.fields ' set cdosys configuration fields use port 25 on smtp server flds .item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdosendusingport .item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp@example.com" .item("urn:schemas:mailheader:message-id") = "0123456789.0123456789@example.com" .update end imsg set .configuration = iconf .from = "from@example.com&quo

yadcf - Dynamic user selectable filter for DataTable -

is there way give option user select dynamically type of filter want applied 1 or more columns? we using datatables jquery plugin display. i'm looking yadcf plugin use filtering(open other options well). yadcf super versatile in being able define filters each column @ design time want ability user select filter type @ runtime. i'm looking yadcf code understand how pointers, ideas , helpful hints appreciated. thanks, ok did simple example allowing user define enable/disable filtering each column. may extend placing more dropdowns , asking type of filtering want. fiddle https://jsfiddle.net/ergec/6yjrrjyr/ html col 1:<select class="colfiltering" data-colnumber="0"> <option value="">no</option> <option value="1">yes</option> </select> col 2: <select class="colfiltering" data-colnumber="1"> <option value="">no</option>