Posts

Showing posts from February, 2015

javascript - Centering a flot chart relative to the chart plotted instead of the canvas size. -

hey i'm working on application uses flot charts extensively. manager tasked me "centering" charts not way right now. by default generate canvas size leaves room on y-axis data, , leads offset canvas centered leaving chart slight offset right. i know nitpicky issue i'm wondering if there's implementable way make chart center relative chart itself, possibly extending right-side canvas equal left, or making y-axis generate in text form leaving chart canvas. i've tried read through flot api solution nothing jumps out @ me. if i'm understanding correctly, looking grid's margin property . grid:{ margin:{ right: 17, top: 17 } } see fiddle here . for comment to set right margin equal left margin dynamically, let flot draw plot once, set right margin equal yaxis's width , redraw plot: p = $.plot( ... p.getoptions().grid.margin.right = p.getyaxes()[0].box.width; p.setupgrid(); p.draw(); updated fiddle .

jquery - Better way to load dropdown list from comma separated string -

i have string of comma separated values. need split string , load each entry in dropdown . have following code job. is there better code reduces number of lines without using other library? code //remove existing entries dropdown $('.ddlasn').empty(); //split string array var arr = result.split(','); //loop through array for(var = 0; i<arr.length; i++) { //add ddl options - text , value $('.ddlasn').append($('<option></option>').val(arr[i]).html(arr[i])); } you can simplify to: $.each(result.split(','), function(i, e) { $('.ddlasn').append($('<option>', { value: e, text: e })); });

ios - Unable to update the model layer upon CoreAnimation completion -

Image
i have following function. it's purpose animate ui elements out of the screen's bounds. func animateelementsout(elements: anyobject...) { var moveoutanimation : cakeyframeanimation = cakeyframeanimation(keypath: "transform"); moveoutanimation.delegate = self; var key1 : nsvalue = nsvalue(catransform3d: catransform3didentity); var key2 : nsvalue = nsvalue(catransform3d: catransform3dmaketranslation(-300, 0, 0)); var values : nsarray = [key1, key2]; var delayamount = 0.0; moveoutanimation.values = values; moveoutanimation.calculationmode = kcaanimationlinear; moveoutanimation.timingfunction = camediatimingfunction(name: kcamediatimingfunctioneasein); moveoutanimation.duration = 0.5; moveoutanimation.additive = true; element : anyobject in elements { delayamount += 0.1; moveoutanimation.removedoncompletion = true; moveoutanimation.begintime = cacurrentmediatime() + delayamount;

osx - Full path to an awk script from within the script itself -

i have awk script, i.e., ascii file executable in linux in first line is: #!/usr/bin/awk -f i execute myscript this, if i'm in same directory: > ./myscript afile or this, if i'm in different directory: > pwd /some_weird_path > /full_path/myscript afile how can have access "/full_path/" within awk script itself? i've tried following without success: argv[0] => /usr/bin/awk argv[1] => afile environ["pwd"] => some_weird_path ideas? this ugly seems work gnu awk on linux. begin { getline cmdline <("/proc/"procinfo["pid"]"/cmdline") nf=split(cmdline,fields,/\0/) print fields[3] } this uglier, should work on system ps implementation, long neither path awk nor path script include whitespace characters: begin { "ps -p "procinfo["pid"]" -ocommand=" | getline cmdline nf=split(cmdline,fields," &

javascript - JQuery css function not persisting its change -

i have "button-bar" div want show once user has clicked on "settings" button. have set button-bar div display:none in css. unfortunately, when settings button clicked, div shows split second, goes away. know why might happening? current code: $(document).ready(function() { $('#settings').on('click', function() { $('#button-bar').css('display', 'inline-block'); }); }); the problem href="" empty, reloading page. put hashtags in them. href="#"

haskell - Why is the return value of head implicitly converted to Maybe? -

i've started learn haskell , practice i've decided create function takes tree, elements have position , size, , returns element located @ position. code looks this: import data.list (dropwhile) data node = node (int,int) (int,int) [node] deriving(eq, show) findnode :: (int,int) -> node -> maybe node findnode loc node@(node (x, y) (width, height) []) = if loc >= (x, y) && loc <= (x+width, y+height) node else nothing findnode loc node@(node (x, y) (width, height) children) = if loc >= (x, y) && loc <= (x+width, y+height) if not $ null nodes head nodes else node else nothing nodes = dropwhile (==nothing) $ map (findnode loc) children this code compiles , runs far can tell, i'm curious 1 thing, why head nodes acceptable instead of just $ head nodes? . that's because nodes has type of [maybe node] . can infact verify annotating explicitly , compiling again: findnode

r - ggplot2 stat_function plots the wrong function -

Image
i want plot loglikelihood function of series of independent bernoulli distributed random variables y parameter p being function (the logistic function) of feature x. logistic function has parameter b. parameter want estimate. want plot loglikelihood function of b. want in r using ggplot2, because want become better in those. my creation of loglikelihood function can , should done better, not point here. problem plotted loglikelihood constant on interval (-5,5). seems wrong. especially, because when call function arbitrary b in interval returns different value. why happen? thank you. library(ggplot2) set.seed(123) # parameters n=100 mu=0 s=2 b<-0.2 # functions logit <- function(x,b){1/(1+exp(-b*x))} # simulation of data x<-rnorm(n,mu,s) y_prob<-logit(x,b) y<-rbinom(n,1,y_prob) df<-data.frame(x,y) # loglikelihood function loglikelihood<-function(b,df){ prd<-1 (i in 1:nrow(df)){ events<-logit(df$x[i],b) nonevents<-1-events prd&l

sql server - Stuff or Insert string before specific group of strings -

i have table containing data in historical table. member_id colors 1 1) red 2) blue 3) green i need modify or select data result-set looks this. member_id colors 1 #1) red #2) blue #3) green in nutshell insert pound before number , closing parenthesis. i tried using charindex have tried did not work. assuming ms sql server... easiest way is: select member_id, replace(replace(replace(colors, '1', '#1'), '2', '#2'), '3', '#3') colors

optimization - Need an algorithm approach to calculate meal plan -

i’m having trouble solving deceptively simple problem. girlfriend , trying formulate weekly meal plans , had brilliant idea optimize buy in order maximize things make it. trouble is, problem not easy appears. here’s problem statement in nutshell: the problem: given list of 100 ingredients , list of 50 dishes composed of 1 or more of 100 ingredients, find list of 32 ingredients can produce maximum number of dishes. this problem seems simple, i’m finding computing answer not trivial. approach i’ve taken i’ve computed combination of 32 ingredients 100 bit string 32 of bits set. check of dishes can made ingredient number. if number of dishes greater current maximum, save off list. compute next valid ingredient combination , repeat, repeat, , repeat. the number of combinations of 32 ingredients staggering! way see it, take 300 trillion years calculate using method. i’ve optimized code each combination takes mere 75 microseconds figure out. assuming can optimize code, mig

java - Populate an array of objects using hashmap -

i new hashmaps , though trying read it, couldn't solve issue. this part of code have issue. public heatmapdata(hashmap<node, arraylist<oddata>> ods) { /* of origins */ node [] row = ods.keyset().toarray(new node[0]); node [] column = new node[row.length]; system.arraycopy(row, 0, column, 0, row.length); oddata [] routes = new oddata[routes_size]; (int i=0; i<routes_size; i++) { oddata temp = new oddata(); // node n = row[i]; routes[i] = temp; //routes = (oddata[]) ods.get(n).toarray(new oddata[0]); } as can see can't find way copy data original hashmap array of objects. i need find first node in array "row", find values hashmpap, populate array "routes[]", , same second node in array "row". seems every time try have miss match error or null value. the program reads 2 files follows: first: 100001 200002 6 100001 200003 9 ............

docker - Change boot2docker memory assignment -

i've been playing around docker on mac need install boot2docker make work. i have pretty powerful machine , resource hungry app want available memory default 1gb 8gb. this i've tried booting boot2dock --memory param boot2docker --memory=8116 boot change config file verbose = true vbm = "vboxmanage" ssh = "ssh" sshgen = "ssh-keygen" sshkey = "/users/mjsilva/.ssh/id_boot2docker" vm = "boot2docker-vm" dir = "/users/mjsilva/.boot2docker" iso = "/users/mjsilva/.boot2docker/boot2docker.iso" vmdk = "" disksize = 20000 memory = 8116 sshport = 2022 dockerport = 2375 hostip = "192.168.59.3" dhcpip = "192.168.59.99" netmask = [255, 255, 255, 0] lowerip = "192.168.59.103" upperip = "192.168.59.254" dhcpenabled = true serial = false serialfile = "/users/mjsilva/.boot2docker/boot2docker-vm.sock" and booting boot2docker boot2docker boot non

Python don't do anything until keystroke -

so need python program or module executes main program once specific key pressed, example f10 key. other modules found (for example getch) executes once any key pressed. since mention msvcrt , i'll assume (windows). you'd different in linux. f10 2-byte return, 00 68 , so... first byte 00 , second byte 68 . there 2-byte return has 224 first byte, you'll want check that, too. i included block on kbhit() because if let block on getch() instead, pick ctrl-c , won't able break out. blocking on gives opportunity. you can make little more generic if you'd like, hardcoded f10 . import msvcrt while true: if msvcrt.kbhit(): first = ord(msvcrt.getch()) if first in (0, 224): second = ord(msvcrt.getch()) if first == 0 , second == 68: break

javascript - Expand if statement -

the code snippet below created have hide or show dropdowns depending on selected. in case below: **translation** if modelyear <= 67 , assyplant=bf or modelyear >=68 display following dropdowns etc. what expand on stating following: if modelyear <=67 , assyplant =bf or modelyear <=67 , assyplant =bc or modelyear >=68 display following dropdowns etc etc etc. already have following working code: // model_year + assy_plant logic if (thisfield == 'model_year' || thisfield == 'assy_plant') { var modelyear = parseint($('#model_year').children('option:selected').text()); if (isnan(modelyear)) { return; } var assyplant = $('#assy_plant').children('option:selected').text(); $('tr#row6').css('display', 'none'); $('tr#row7').css(

java - Public class requires public members (when accessing members)? -

i noticed in java book, in section packages , private modifier, code redundantly used private on class , members of class being accessed outside of package. package bookpack; public class book { private string title; private string author; private int pubdate; public book(string t, string a, int d) { title = t; author = a; pubdate = d; } public void show() { system.out.println(title); system.out.println(author); system.out.println(pubdate + "\n"); } } when remove public show() , eclipse gives error stating member cannot accessed (when attempting package). understand because not public , therefore cannot accessed outside package. however, since class public, thought members of class public , unless otherwise specified. follow "general specifications here, specific specifications later" style, similar inheritance. how cannot call dynamic object static method. why public tag

How to grab .// with regex python? -

Image
why not work? in regex finder, matches. i'm trying grab .// in strings pat = '[\.\/]+(?!(docx|doc|pdf))' bad = re.compile(pat) bad.findall(tails[1]) print tails[1] ".//2005 neuropathophys.doc" this pattern seems work on regex matcher website http://regex101.com/ your regex below match .// not followed docx or doc or pdf , \.//(?!docx|doc|pdf) demo

javascript - Select element that onchange is being triggered from - jQuery -

i trying create form when input has value put in , un-focused trigger event. here code far. $("#live-form input").on('change', function(e) { var value = $(this).val(); var key = $(this).attr("name"); $.post('update-form.php', {key:value}, function(data) { $("#form-status").html(data); }); }); and update-form.php script returns following response testing only: key: key - value: value when change jquery selector #username works fine. otherwise doesn't @ all. html requested: <div id="form-status"></div> <form id="live-form" action="" method="post" autocomplete="off"> <div class="form-contain"> <label for="username">username:</label> <input type="text" name="username" id="username" placeholder="username:" value="" maxleng

Soap XMl Parsing in android -

i getting xml <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <ns2:authenticateresponse xmlns:ns2="http://auth.mobility.kra.kuali.polus.com/" xmlns:ns3="http://rice.kuali.org/kim/v2_0"> <principal> <ns3:principalid>10000000049</ns3:principalid> <ns3:principalname>shields</ns3:principalname> <ns3:entityid>10048</ns3:entityid> <ns3:active>true</ns3:active> <ns3:versionnumber>1</ns3:versionnumber> <ns3:objectid>f07352db67502cf0e040007f0100035a</ns3:objectid> </principal> </ns2:authenticateresponse> </soap:body> </soap:envelope> how parse kind of xml in android. i had tried not working xmlparser parser = new xmlparser(); document doc = parser.getdomelement(xml); // getting dom element nodelist nl = doc.getelementsbytagname("soap:body"); // looping through item nodes &

c++ - Forward class declaration is interchangeable with the class keyword in the place of use? -

are these 2 equivalent? code 1: class b; class { public: b fun1() const; b* m_b; }; extern void myfun( const b& b ); code 2: class { public: class b fun1() const; class b* m_b; }; extern void myfun( const class b& b ); or there problematic points use programming style presented in code 2? these different if have enclosing scope. case 1: class b { }; namespace test { class b; // declares test::b class { public: b fun1() const; // refers test::b b* m_b; // refers test::b }; class b { int x; }; // defines test::b } case 2: class b { }; namespace test { class { public: class b fun1() const; // refers ::b class b* m_b; // refers ::b }; class b { int x; }; // defines test::b } more details: class b; 1 of 2 things. it's either redeclaration, or forward declaration introduces name b current scope (§9.1 [class.name]/p2 of standard). cl

java - My project is connecting to mysql database on my local tomcat server 6 but not connecting on tomcat6 in hosting platform -

my project working fine on local machine. using private jvm hosting provided unlimitedgb.com, project working fine on eclipse tomcat server 6 when deploy project on tomcat server6 provided in ngasi panel, not connecting database. had verified connection string many times. had exported mysql file .sql file phpmyadmin panel provided in control panel verified username , password, database name , port number codded in "dblayer.java" (myproject/java resources :src/com.my.classes) several times. i using "mysql-connector-java-5.1.26-bin.jar" java jason.jar additional libraries project. both files placed on "myproject/webcontent/web-inf/ib/" , added "myproject/java resources:src/libraries/ above location. using jre system library [jre7] in "mysql-connector-java-5.1.26-bin.jar" present default had added mysql connector not present in apache tomcat6 present @ hosting platform. json.jar working fine on server in hosting platform. had uploaded pr

JQuery mobile code won't work on rails 4 app -

i have simple jquery mobile 'listview' displays on fresh rails 4 app. however, on application working blank page. i made sure install jquery mobile on fresh rails app same way installed on existing app. below gem file. can imagine there conflict. have precompiled assets several times might have jquery code not displaying? the following line appears in view source contains jquery mobile code, however, webrick development server's output shows there not asset. <script src="/assets/jquery.mobile.js?body=1"></script> after having installed jquery mobile there noticeable delay of 5 seconds before page loads on app. gem 'rails', '4.0.0' group :production gem 'pg' end group :development gem 'sqlite3' end gem 'bcrypt-ruby', '~> 3.0.0' gem 'aws-s3', :require => "aws/s3" gem 'foundation-rails' gem 'rf-rest-open-uri' gem 'image-picker-rails', '

php - How to return results if more than 60% of string is matching -

i have table product name saved. want execute select query statement 60% or more results matching for example: if types "verifone 500", product: 1) verifone vx500 2) verifone5 3) verifon00 4) verifone 50" should matched 60% or more same searched product. have tried code select `product_name` product_data `product_name` '%verifone 500%' but not getting desired result. hope body can help? you should go fulltext search myisam table engine! if table engine myisam create fulltext index field product_name . then try query like: select `product_name`, match (`product_name`) against ('verifone 500' in natural language mode) match `product_data` having `match` > 0.5 order `match` desc

php - How to write curl get request on python to decrease parsing time -

i have basic curl request work site api in php: $headers = array( "content-type: text/xml;charset=\"windows-1251\"", "host:api.content.com", "accept:*/*", "authorization:qwerty" ); $ch = curl_init(); curl_setopt($ch, curlopt_url,"https://api.content.com/v1.xml"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 60); curl_setopt($ch, curlopt_autoreferer, true); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_ssl_verifypeer, false); $data = curl_exec($ch); $f = new simplexmlelement($data); #echo $data; $total = $f['total']; curl_close($ch); } what best way write in python in case, request used in separate subprocesses decrease parsing time? you can use requests , requests document; >>> import json >>> url = 'https://api.github.com/some/endpoint' >>> payl

Python, CherryPy, Windows Service, and BackgroundTask - Tasks not recurring as expected -

i trying series of python scripts update every 60 seconds , serve json via cherrypy on windows (for wmi capabilities) , managed windows service. in short, if run code in console outside service, tasks execute backgroundtask class regularly , without problems. once wrapped in cherrypy windows service, execute once or twice, , stop working after (the json stops changing). this cherrypy 3.3.0 on activestate python 2.7 (community). running code below, script works (import snmp python script run every 60 seconds, in form). import cherrypy cherrypy.lib.static import serve_file import cherrypy.process.plugins import win32serviceutil import win32service import win32event import os import snmp class myserver(): @cherrypy.expose def snmp_ajax(self): cherrypy.response.headers['content-type'] = 'application/json' return snmp.json def snmp_callback(): global snmp_data snmp.generate_json(snmp_data) snmp_data = cherrypy.process.plugins.back

convert unicode string to ASCII in java which works in unix/linux -

i have tried using normalizer string s = "口水雞 hello Ä"; string s1 = normalizer.normalize(s, normalizer.form.nfkd); string regex = pattern.quote("[\\p{incombiningdiacriticalmarks}\\p{islm}\\p{issk}]+"); string s2 = new string(s1.replaceall(regex, "").getbytes("ascii"), "ascii"); system.out.println(s2); system.out.println(s.length() == s2.length()); i want work in unix/linux , there ascii character class matching code points in ascii set: string s = "口水雞 hello Ä"; string s1 = normalizer.normalize(s, normalizer.form.nfkd); string nonascii = "[^\\p{ascii}]+"; string s2 = s1.replaceall(nonascii, ""); system.out.println(s2); system.out.println(s.length() == s2.length()); as joop eggan notes , java string , char types utf-16. can have ascii-encoded data in byte form: byte[] ascii = s2.getbytes(standardcharsets.us_ascii);

r - keep colour palette constant between plots -

Image
i need compare 2 maps of same quantities, keep colour palette constant in 2 graphs, easing comprehension, looks don't how so. should set limits (e.g. minimum between plots assigned low , highest level high?) is there easy way so? i new this, sorry if solution banal, went through lot of blog posts looks not finding anything. my code: fin<-get_map("helsinki",zoom=12) ggmap(fin, legend="bottom")+ geom_polygon(data=a,aes(x=a$long,y=a$lat, id=id, fill=test_statistics), alpha=0.1, colour="white") to give idea, image and another it not clear @ all! images still need bit of "prettyfying" give idea basically in this question , discrete (factor) values i can't reproduce plots because you've not given data, setting limits in scale_colour_gradient should work. see: http://docs.ggplot2.org/0.9.3.1/scale_gradient.html under "tweak scale limits" (second example) hadley says: se

php - after upload some of the image are missing -

Image
i encountered problem when user upload photo server , of image missing or image wrecked. is there exist experience problem , why happen , how can handle it? i'm using http://flourishlib.com/docs/fupload class, $uploader = new fupload(); $uploader->setmimetypes( array( 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' ), 'isnotimage' ); $uploaded = fupload::count('file'); ($i=0; $i < $uploaded; $i++) { try { $files[] = $uploader->move(file_path ."public/_file/uploads/slider/", 'file', $i); } catch (exception $e) { $message[] = $e->getmessage(); return false; } } it's works me in local without problem

c# - Throttle Messages Per Second -

i attempting throttle amount of messages send smpp smc(server). need throttle them smc not throttle , drop messages. this have tried: double _client.sendspeedlimit = 20; if (math.abs(_client.sendspeedlimit) > 1e-6 && _lastsubmit != datetime.minvalue) { check submit speed , wait next time double elapsed = (datetime.now - _lastsubmit).totalmilliseconds; if (elapsed < 1000f / _client.sendspeedlimit) { int interval = convert.toint32((1000f / _client.sendspeedlimit) - elapsed); thread.sleep(interval); } } and... int left = (int)(start.addseconds(1.0 / (double)_client.sendspeedlimit) - datetime.utcnow).totalmilliseconds; if (left > 0) { mobiledal.inserterror(settings.default.mobileconnectionstring, "throttled: " + _clientfriendlyname, "", _accountid); console.writeline("throttled: " + _clientfriendlyname, "", _accountid); while (left > 0) { thread.sleep

How to Display Page Excerpts in WordPress Themes -

my search result doesn't show excerpt content of pages on wordpress show post advise please taken http://codex.wordpress.org/function_reference/add_post_type_support <?php add_action('init', 'my_custom_init'); function my_custom_init() { add_post_type_support( 'page', 'excerpt' ); } ?> adds excerpt support 'page' post type. paste code themes functions.php file (ref http://codex.wordpress.org/functions_file_explained )

c# - Generate dynamic 'Span' controller -

i trying create dynamic span controller ,because need insert drop down list created code on it. here in page load creating list of ddl can see here : (int = 0; < numberofquestion; i++) { dropdownlist anslist = new dropdownlist(); anslist.datasource = clsvoanswer.answer; anslist.databind(); anslist.autopostback = true; ddll.add(anslist); } in page create span tag runs in server can see here : for (int = 0; < numberofquestion; i++) { response .write("<div class='rows-score' style='background:transparent'>"+ "<div class='columns-score'> " + "<span>" + listquestion[i].question + "</span>" + "</div>&

Cell coloring in google-spreadsheet fails if it is called from a cell, but works ok when called from the script. -

i have created following simple function: function test(r,c) { var sheet = spreadsheetapp.getactivespreadsheet().getactivesheet(); sheet.getrange(r,c).setbackground("red"); return 1; } in spreadsheet, write "=test(row(),column()) this results in error following message: error: not have permission call setbackground (line 3). it no problem if create function call in script follows: function test_the_test(){ test(5,4); } why can't call test function spreadsheet cell? thank in advance as explained in documentation , custom functions return values, cannot set values outside cells in. in circumstances, custom function in cell a1 cannot modify cell a5. of course true other methods such setbackground etc.

jnlp - Starting Java Webstart App with older installed JRE Version -

is there chance start jnlp jre 7_17 while jre 7_45 latest version installed on system? first tried editing jnlp file , changing version 1.5+ 1.7.0_17. wasnt working. after research, bug. then tried start jnlp file commandline , javaws.exe bin path of older jre version. still newer 1 used. are there chances have many jres installed , open different webstart apps version supported supplier ? thanx marcus you may not start jnlp file specific java version - 1 installed (and default in webbrowser) used start jnlp. can specify java version application/applet started afterwards. here description: "the version attribute refers, default, platform version (specification version) of java(tm) platform standard edition. defined platform versions 1.2, 1.3, 1.4, 1.5 , 1.6. (a platform version not contain micro version number; e.g., 1.4.2.) exact product versions (implementation versions) may specified. including href attribute. example, 1.3.1_07, 1.4.2, or 1.5.0"

How to let Composer import working copy of existing (git) folder? -

i've got couple git projects , i'm working in 2 @ same time. want import 1 of project other using composer. try using following lines in composer.json file: "repositories": [ { "type": "vcs", "url": "../otherproject" }, { "type": "composer", "url": "http://our.local.stuff.com" } ], this seem import project, latest commit in git repo. instead, import existing files how are, don't have commit every little change in project. does know how possible? tips welcome! composer clone remote repository, , can work inside folder git repository when located anywhere else. saving changes files make them effective immediately. adding , committing them persist them in repo locally. pushing branch makes changes available others. the thing should aware of using composer command might destroy uncommitted changes. careful when installi

django - scrappy status page for failed spiders -

i have made spider crawl news , here code class abcspider(xmlfeedspider): handle_httpstatus_list = [404, 500] name = 'abctv' allowed_domains = ['abctvnepal.com.np'] start_urls = [ 'http://www.abctvnepal.com.np', ] def parse(self, response): if response.status in self.handle_httpstatus_list: return request(url="http://google.com", callback=self.after_404) hxs = htmlxpathselector(response) # xpath selector sites = hxs.select('//div[@class="marlr respo-left"]/div/div/h3') items = [] site in sites: item = newsitem() item['title'] = escape(''.join(site.select('a/text()').extract())).strip() item['link'] = escape(''.join(site.select('a/@href').extract())).strip() item['description'] = escape(''.join(site.select('p/text()').extract())) item = request(item['link'],meta={'item'

Gnuplot conditional plotting -

Image
i need use gnuplot plot wind direction values (y) against time (x) in 2d plot using lines , points. works fine if successive values close together. if values eg separated 250 degrees need have condition checks previous y value , not draw line joining 2 points. condition occurs when wind dir in 280 degrees 20 degrees sector , plots messy eg north wind. data time dependent cannot use polar plots except @ specific point in time. need show change in direction on time. basically problem is: plot y against x ; when (y2-y1)>= 180 break/erase line joining successive points can give me example of how this? a sample data file is: 2014-06-16 16:00:00 0.000 990.081 0.001 0.001 0.001 0.001 0.002 0.001 11.868 308 002.54 292 004.46 00 2014-06-16 16:10:00 0.000 990.047 0.001 0.001 0.001 0.001 0.002 0.001 11.870 303 001.57 300 002.48 00 2014-06-16 16:20:00 0.000 990.014 0.001 0.001 0.001 0.001 0.002 0.001 11.961 334 001.04 314 002.07 00 2014-06-16 16:30:00 0.000 990.014 0.001 0.001 0.

html - Remove inline style for ajaxtoolkit Combobox -button -

i using ajaxtoolkit combobox in page... trying change width of combo-button . couldnot. because has inline style default.. i tried following code add style //combo css .comboclass .ajax__combobox_buttoncontainer button { border-radius: 0px; box-shadow: 0px; width :12px; height:12px; } but border-radius , box-shadow styles applying width& height not applying .. because combobox button got default inline styles.. cant remove line styles too.. please post me suggestions.... add javascript function search , strip attributes on document ready. jquery way is: $(document).ready(function() { document.find(".ajax__combobox_buttoncontainer").removeclass("ajax__combobox_buttoncontainer").addclass("myawesomeclasswithcooldimensions"); }); make sure css has myawesomeclasswithcooldimensions class.

jquery - Can't handle submit function -

i want show error message viewbag can't handle button click function. couldn't find reason. aim show viewbag message if isn't null. in view: $(function () { $("#changecompanyuserinfobutton").submit(function (e) { e.preventdefault(); var deneme = viewbag.messageforallres; if(deneme != null) alert(deneme); }); }); <button type="submit" id="#changecompanyuserinfobutton">changecompanyuserinfovalues</button> just remove hash(#) id in html , see works. <button type="submit" id="changecompanyuserinfobutton">changecompanyuserinfovalues</button>

android - How to include maven dependencies in Cordova command line build? -

i have cordova project uses maven manage dependencies, when "cordova build" in command line, cannot find maven depencencies causing compile fail. how include maven dependencies in cordova command line build? pointer appreciated.thanks you can .gradle files cordovalib/cordova.gradle , cordovalib/build.gradle via gradle in maven found different approach efficient. git clone http://github.com/my_maven_repo cd , pom.xml file go <build><plugins> tags , existing plugins add these 2: <plugin> <artifactid>maven-assembly-plugin</artifactid> <configuration> <archive> <manifest> <mainclass>fully.qualified.mainclass</mainclass> </manifest> </archive> <descriptorrefs> <descriptorref>jar-with-dependencies</descriptorref> </descriptorrefs> </configuration> </plugin> <plugin> <artifactid>maven-asse

How do I reference a variable by its name in SASS? -

i working on sass framework has list of variables turn on , off features. for example: // atoms: $use-pa: true; $use-pt: true; $use-pb: true; i want able following in case variable turned off. @mixin requires($collection: ()) { @each $var in $collection { #{$var}: true; } } and @include requires(( $use-pa, $use-pt, $use-pb )); i looking way change variable's value name... if possible. #{} not work. if want change variable's value, don't use interpolation. here's sassmeister play with.

Does the Yosemite (OSX 10.10) feature of xcode live views work with NSView on OSX? -

i'm trying determine if live view feature works nsview on osx 10.10, or ios @ moment? it works great uiview ios projects, haven't been able osx projects work. yes work. need add same symbols ibdesignable (before class interface declaration) , ibinspectable (before property want edit in ib) in right places in view class header , sure nib or storyboard has class set in tge inspector in ib. you need note must properties , limited in type. sometimes ib still little flaky recognizing right away, might need build or reopen tab nib or storyboard. also expect mileage may vary subclasses of more complex views , remember works objects descendants of nsview @ point. no nscell descendants.

c# - How to Center Image in ViewBox -

i populating viewbox image, although cannot seem center on image. i've tried setting viewbox fill uniformtofill, centering image vertically , horizontally, etc , nothing seems work. xaml <stackpanel horizontalalignment="center" verticalalignment="center"> <viewbox maxwidth="500" maxheight="500" name="vb1"> <image x:name="myimage"/> </viewbox> </stackpanel> xaml.cs bitmapimage bitimg = new bitmapimage(new uri("/mynewlink.jpg", urikind.relative)); myimage.source = bitimg imagesource; set verticalalignment , horizontalalignment of viewbox. have set content alignment of image.

jquery - pause timer until ajax completes -

i wrote following timer function check database every x seconds... pause timer until ajax completes , once complete start again. currently, counts down 0 x seconds , when reaches 0 ajax check occurs. timer resets x seconds 0 reached , continues run until stopped. i loading number of images webpage ajax may take time load these ... reason pause. // start timer $('#dtstart').on('click', function () { if(timerstatus != true) { var timercount = $('#dtrefresh').val(); $("#dtstart").addclass('hide'); $("#dtstop").removeclass('hide'); } function countdown(count) { if(timerstatus != true) { timerstatus = true; timerid = setinterval(function() { count--; $("#dttimer").html(count); if(count == 0) { $("#dttimer").html(count); count = timerc

c# - How to tokenize a paragraph into words? -

i have sentence: var input = @"i go to http://www.google.com.i don't cats."; i want try find words in sentence is. need string in term of words. when string stripped = regex.replace(input,"\\p{p}", ""); , i go to httpwwwgooglecomi dont cats expected. is there clever way i go to http://www.google.com dont cats instead of having lot of if then conditions. my problem not know how can detect urls in reliable way able treat them single word. tried lucene here terms pulled out: term=i term=go term=http term=www.google.com.i term=don't term=like term=cats with current input, can use this: \b(?:(?<=http://\s*?)(?!www)\w+\.\w+|(?!www)[\w']+(?!://))\b see the demo . of course begs question "what's acceptable word", expression can tweaked varying requirements , conditions. in c#: var myregex = new regex(@"\b(?:(?<=http://\s*?)(?!www)\w+\.\w+|(?!www)[\w']+(?!://))\b", regexoptions.mu

Multi-projects Maven compilation issue -

i'm experiencing trouble trying build maven project multi-modules project. in main pom have following modules : <modules> <module>modulea</module> <module>moduleb</module> <module>modulec</module> </modules> when comes build third module (that includes 2 others) i'd generate wsdl java2ws goal classnotfoundexception error (trace below) guess occurs because class contained package modulea. how can specify in java2ws command class contained in module ? ... <execution> <id>process-classes-reclamacion</id> <phase>process-classes</phase> <configuration> <classname>com.classx</classname> <genwsdl>true</genwsdl> <verbose>true</verbose> </configuration> <goals> <goal>java2ws</goal> </goals> </execution> ... grave: failed execute goal org.ap

c++ - STL set with custom comparator allows duplicate elements -

the following code simplified example produces problem. a number of strings (char*) inserted set, many of non-unique. duplicate strings should detected , pointer original inserted should returned; however, doesn't happen , inserted string inserted again if not present. the resulting set should consist of: "aa", "bb", "cc". output shows set ends with: "bb", "cc", "aa", "bb". changing string first inserted seems change duplicate 'allowed.' the digit prefix on strings not used, added ensure each string has unique pointer; problem still exist without them. using default comparator , non-prefixed strings work expected, compares pointers; prefixing strings results in unique pointers , strings inserted. #include <iostream> #include <set> #include <cstring> using std::cout; using std::endl; using std::set; using std::pair; typedef set<const char*>::const_iterator set_iter;

php - $this->Agreements->save() - create only one record, why? -

i need read records table agreements, make changes in filed payments, , update records, save table. so, problem is, save() create empty record. not update exists record. show how: reading table: $agreements = $this->agreement->find('all'); $payments = $this->payment->find('all'); manipulation on fields (part of)(example): $id=0; foreach ($agreements $agreement): ($i=$first_agreement; $i<=$last_agreement; $i++){ if ( $agreement['agreement']['agreement_number']==$i){ $agreements[$id]['agreement']['payment']=$payd[$i]; } } $id++; endforeach; writting table: $this->agreement->save(); a echo debug($agreements) shows correct array, have tryed : $this->agreement->save($agreements); or $this->agreement->save($this->request->data); can help/explain me how write record? cake 2.5.2 php : 5.4.4-14 model::save() saves single record. if wa

How to read the last record in SQLite table? -

is there way read value of last record inserted in sqlite table without going through previous records ? ask question performance reasons. there function named sqlite3_last_insert_rowid() return integer key recent insert operation. http://www.sqlite.org/c3ref/last_insert_rowid.html this helps if know last insert happened on table care about. if need last row on table, regardless of wehter last insert on table or not, have use sql query select * mytable rowid in ( select max( rowid ) mytable );

Why does object.__new__ with arguments work fine in Python 2.x and not in Python 3.3+? -

why following code work fine in python 2.x , not in python 3.3+: class testa(object): def __new__(cls, e): return super(testa, cls).__new__(testb, e) class testb(testa): def __init__(self, e): print(self, e) testa(1) python 2.7.6 output: (<__main__.testb object @ 0x7f6303378ad0>, 1) python 3.1.5 output: __main__:3: deprecationwarning: object.__new__() takes no parameters <__main__.testb object @ 0x7f2f69db8f10> 1 python 3.2.3 , 3.2.5 output: <__main__.testb object @ 0xcda690> 1 python 3.3.5 , 3.4.1 output: traceback (most recent call last): file "<stdin>", line 1, in <module> file "<stdin>", line 3, in __new__ typeerror: object() takes no parameters object.__new__ has ignored arguments, , has issued deprecationwarning @ least since python 2.6. the reason why aren't seeing deprecationwarning in 2.7 , 3.2 since 2.7 , 3.2 deprecationwarning has been suppressed def

java - TableView doesn't update all columns -

i'm trying javafx making simple applications. right i'm working on can called "employees database" mean store data in table , tree, tree sorts employees department. when hit "add worker" label in menubar hbox displaying, , after filing textfields , clicking "add" button written data should appear in table. problem tableview updates of columns except "years worked" , "department" column. read tips cannonical variable names proper valuefactory usage stil can't on this. public class main extends application { wtable table = new wtable(); wtree tree = new wtree(); wmenu menu = new wmenu(); wtextfield addfirstname = new wtextfield("first name"); wtextfield addsecondname = new wtextfield("second name"); wtextfield addlastname = new wtextfield("last name"); wtextfield adddep = new wtextfield("department"); wtextfield addyears = new wtextfield("years worked"); wtextfield addsa

Can I use `git checkout --patch` non-interactively? -

i want reset contents of working directory match revision without changing commit current branch pointing to , git reset does. git checkout --patch this, interactively, requiring me answer yes every change want reset. annoying when i'm resetting lot of changes, in cases i'd rather reset everything. is there way use git checkout --patch (or equivalent) non-interactively? git read-tree -um commit resets index , worktree commit (the -m option says merge what's being read index -- 1 tree , index bit of degenerate case), u option says update worktree when done).

loops - Visual basic textbox not refreshing -

i'm writing code in visual basic compute primes. program runs in loop, , i'm adding new primes textbox, remains blank until loop finishes. how can add text textbox while in loop? you caclulating primes on ui thread, freezing ui while loop runs. bad user experience: textbox not updating 1 symptom. split off worker thread caculation , invoke ui thread ui updates.

css - Bootstrap Jumbotron -

how align button within jumbotron, want stick bottom of jumbotron? know text-center, centers button/text, want @ moment of content. <div class="container text-center"> <div class="jumbotron" style="background-color:#; background-image: url('img/jumbo-bg.png'); background-position: 50% 50%; height:600px;"> <a href="#register" class="btn btn-success" data-toggle="modal">register</a> </div> </div> you can use following: <a href="#register" class="btn btn-success" data-toggle="modal" style="position:relative; top:500px">register</a> the position of element relative top property within parent.

c++11 - Squish A Bunch Of Arrays Together C++ -

is there way take 2 pieces of heap allocated memory, , put them efficiently? more efficient following? for( unsigned int = 0; < length_0; ++i ) addtoarray( buffer, array0[ ] ); for( unsigned int = 0; < length_1; ++i ) addtoarray( buffer, array1[ ] ); for copying memory byte byte, can't go wrong memcpy . that's going fastest way move memory. note there several caveats, however. one, have manually ensure destination memory big enough. have manually compute sizes of objects (with sizeof operator). won't work objects ( shared_ptr comes mind). , it's pretty gross looking in middle of otherwise elegant c++11. your way works , should fast. you should consider c++'s copy algorithm (or 1 of siblings), , use vector s resize on fly. use iterators, nicer. again, should fast memcpy, added benefit far, far safer moving bytes around: shared_ptr , ilk work expected.

python find max value and print first 5 lines of file -

i trying program,where have directory , having list of text files,if find "color=" find fuzzy value of 'filename' , 'starting line of file',so: i need : find max value of fuzzy value , need find first 5 lines file having max value i did coding can find fuzzy value dont know how find max value , print first 5 files having maximum fuzzy value.please help! import os fuzzywuzzy import fuzz path = r'c:\python27' data = {} dir_entry in os.listdir(path): dir_entry_path = os.path.join(path, dir_entry) if os.path.isfile(dir_entry_path): open(dir_entry_path, 'r') my_file: line in my_file: part in line.split(): if "color=" in part: print part string1= "filename:", dir_entry_path print(string1) string2= "start line of file:", list(my_file)[0]