Posts

Showing posts from June, 2014

Background proccess in ruby script with heroku -

i want info twitter project, i'm using tweetstream gem, , works in code, need done background process in heroku script. i'm using event machine gem so, , works in computer, haven't been able make run on heroku on it's own. i've read need use procfile , worker process, can't make work, on local works fine. i'm new background process , working servers. heroku dynos not support background processes in "free" or "hobbyist" tiers. here heroku documentation on background jobs . it costs $30 bucks month add on. there other implementation hurdles overcome local server vs. heroku background jobs. best starting point can give heroku not support background jobs default. have "scale worker dynos"

javascript - Why does this lose sort-order? -

for purposes of our frontend app, need ingest array of objects (say 20), convert array key/value object. data = [ {name: 'first', uid: 789, start: '2016-01-20 08:00:00'}, {name: 'second', uid: 492, start: '2016-01-20 15:00:00'}, {name: 'third', uid: 324, start: '2016-01-20 10:00:00'}, {name: 'fourth', uid: 923, start: '2016-01-20 14:30:00'}, // ... ]; i run sort on start data.sort(function (a, b) { var astart = new date(a.start), bstart = new date(b.start); if (astart < bstart) return -1; if (astart > bstart) return 1; return 0; }); then, purpose of quick-access data based on uid, loop through sorted array convert k/v object: var stored = {}; (var = 0; < data.length; i++) { stored[data[i].uid] = data[i]; } this allows me stored[uid] instead of having loop through data every time need index of given object. issue in looping through , creating st

Cancel git merge but keep local changes -

i started git merge, made local changes want keep. no longer want merge, , instead continue work on local changes. how do this? first, copy folder you're working in in case bad happens. git pretty bulletproof, if start using git reset --hard , it's possible bad things happen. then, git commit --patch , picking changes want keep , leaving merge did. once you've committed changes, git reset --hard , , merge should gone, changes should still there.

javascript - Does Karma rely on your source code being available in the browser's global scope? -

this seems way can jasmine tests run through karma @ moment: src/js/voice.js describe("speak", function () { var input = "success"; var output = voice.prototype.speak(input); it("should return input value", function () { expect(output).toequal(input); }); }); spec/voicespec.js var voice = function () {}; voice.prototype.speak = function (string) { return string; };

visual studio 2010 - C++ VS2010 no linker in project->properties -

i have problem .lib files not found. check linker properties. however, in project->properties, cannot find linker tab. missing here ? actually, fear not looking @ project properties, @ properties solution or whatever. project (which icon in vs instance), or can @ project properties ? thanks !! if there no linker options, possible project set build *.lib. in case able select 'librarian' on left of project options. can modify project configured build going general , changing configuration type. to project properties, right click on project in solution explorer window , click on properties.

machine learning - Which standard deviation of the cross-validation score? -

when doing cross-validation model selection, found there many ways quote "standard deviation" of cross-validation scores (here "score" means evaluation metric e.g. accuracy, auc, loss, etc.) 1) 1 way calculate standard deviation on mean of scores of k folds (= standard deviation of k folds / sqrt(k)). 2) second way calculate standard deviation of scores of k folds. example can found here: http://scikit-learn.org/stable/auto_examples/svm/plot_svm_anova.html 3) way don't understand. seems calculate standard deviation of k folds / sqrt(n) n size of dataset... http://scikit-learn.org/stable/auto_examples/exercises/plot_cv_diabetes.html personally think 1) correct, care more standard error on sample mean (here = average score of k folds validation) rather standard deviation of sample. can explain way preferred?

passwords - How to lock a PDF File after a few days -

is there way lock pdf file after given number of days? example making document in ms word , export pdf file password locks pdf file after 3 days... user can open pdf file , read content after 3 days he/she cannot open anymore unless he/she knows password.

ios - How should i deal with presentView when i receive remote notification and try to back my rootviewcontroller to push next viewcontroller -

present viewcontroller , lock screen(the present view never pushed self.navigationviewcontroller.viewcontroller) lock iphone screen send promotion info slide remote notification wish app can dismiss presentview , rootviewcontroller, action (push viewcontroller or present new viewcontroller). question: can't find presentview dismiss it

c++ - Python C API - How to construct object from PyObject -

i'm looking find out if there's nice, "native" way construct object given pyobject* known type. here code stands: c++ void add_component(boost::python::object& type) { auto constructed_type = type(); // doesn't construct anything! } python o = gameobject() o.add_component(cameracomponent) my code executing entire function fine, constructor never triggered cameracomponent . so question is, how i, given pyobject* known a type, construct instance of type? many in advance. if boost::python::object references type, invoking construct object referenced type: boost::python::object type = /* py_type */; boost::python::object object = type(); // isinstance(object, type) == true as in python object, accepting arguments python boost::python::object allow type of object, not type. long object callable ( __call___ ), code succeed. on other hand, if want guarantee type provided, 1 solution create c++ type represents python type,

How to change the major order of lists in python? -

i have list of n lists, each sub-list containing m elements. how create list of m lists n elements each, containing n-th elements initial lists? let's have this mylist = [[1, 2, 3],[4, 5, 6]] i want have [[1, 4],[2, 5],[3, 6]] performance important. have sublists of millions of elements (though, 1 dimension small: 1.000.000 x 8 ) this give tuples, it's trivial extend contain lists: zip(*mylist) i.e. [list(i) in zip(*mylist)]

how to get a pointer of element's value in a double-linked list (go-lang) -

i want modify element's value in double-linked list, don't know how pointer, because element's value nil interface defined go-lang itself. far know is, must type assertion before element's value like: val, ok := ele.value.(type) if ok { // something... } but if modify val useless. hint? thanks. there 2 pretty straight forward options. they're going involve type asserting because you're using interface{} you can store pointer , type assert: var q interface{} var int q = &i *(q.(*int)) = 5 you can reassign it: var q interface{} q = 5 b := q.(int) q = 2*b i think reassigning makes sense. if you're doing in function need return new value. i'm sure there other ways change around, think simple best. of course in real work checking nice.

powershell - Parse date from text file and extract lines where the date is greater than X -

i have client uses third-party software store confidential medical information. need find out users have opened particular record in database. have been in touch vendor, , way log in text file on each individual computer(apparently). need parse text file each computer pull out information need. here anonymous sample of information in text file - have added spaces between each line readability. log in.|10/03/2012|01:12:45|dr john smith|3|fs01|windows 7 domain controller terminal services service pack 1 (6.1 build 7601)|3.12.1 progress note - new record opened|10/03/2012|01:13:33|dr john smith|666241|8463|richard test^05/09/1956|.f.|.t.|1|fs01 progress note - discarded user|10/03/2012|01:14:29|dr john smith|666241|8463|richard test|.f.|.t.|fs01 i can pull out line record name in question i.e. "richard test", these logs go way 2012. have idea how can parse date each line can pull after 01/01/2016 example? import-module activedirectory $computers = "fs01"#

Background colour value between JavaScript and jQuery -

i trying background colour of coloured box when clicked , subsequently storing in variable using either javascript or jquery. although trivial information, noticing is, javascript , jquery show in different manner. for example, coloured box using red (in css, giving background-color: red). therefore, when click box id ( #box ) using following code in javascript var bcolour = document.getelementbyid("box").style.backgroundcolor; console.log(bcolour) gives me value red . whereas same in jquery var bcolour = $(#box).css("background-color"); console.log(bcolour) gives me value rgb(255, 0, 0) . is there way jquery display bcolour value identical javascript shows? jquery.css uses getcomputedstyle function. ref there no difference between getcomputedstyle(object).getpropertyvalue(property) , jquery.css for example document.getelementbyid("mydiv").style.backgroundcolor // return red; getcomputedstyle(document.getelementb

c++ - Is assignment equivalent to load/store for std::atomic<bool> -

i see potentially answered in question must call atomic load/store explicitly? . so sake of clarity restate question succinctly in hopes future readers find clear. is std::atomic<bool> b(false); bool x = b; same std::atomic<bool> b(false); bool x = b.load(); and std::atomic<bool> b(false); b = true; same std::atomic<bool> b(false); b.store(true); if indeed case then: why have 2 options? apparent benefit? is practice when dealing atomics prefer more verbose load()/store() on potentially confusing assignment(=) mean either depending on whether lhs or rhs atomic. note aware of fact both variables cannot std::atomic i.e lhs , rhs not possible read , write atomically in 1 instruction. yes, same. think reason overloaded operators provided convenience. not mention making easier convert existing code use atomics. personally, prefer explicit load , store always. think it's better practice , forces remember you're de

html - Putting Banner Behing Adsense -

i setting adsense website @ moment , trying set background-image behind ad if visits page ad-block there image politely asking them turn on if support website. currently, have wrapped adsense code in div , set background-image on it, when adblock software able detect , block image behind it. able tell me correct this? cheers html - <div class="ad-alert"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- listings banner --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-9407013200292589" data-ad-slot="7535806952"></ins> <script>(adsbygoogle = window.adsbygoogle || []).push({});</script> </div> css - .ad-alert { width: 728px; height: 90px; background-image: url("../images/ad-alert-banner.png"); } okay, solved myself. trick

Amazon Redshift Copy Command invalid characters -

Image
im trying copy above data sql server amazon redshift. unfortunately found characters in catdesc column replaced '?'(i.e., question mark). can 1 suggest on this? redshift should able load in utf8 characters, need use varchar data type enough space handle multibyte characters. there's more information here: loading multibyte data amazon s3 , here: handling utf-8 characters in redshift

dealing with 3 different user + admin user in django? -

i getting django , using drf build restful api have 4 different users admin , has access admin panel brokers can on site cannot access admin panel buyers can 2 action buy , search man in middle can except 1 thing way doing right have baseclass shared fields between users class siteuser(models.model): name = models.charfield( max_length=255, null=false, blank=false, db_index=true) email = models.emailfield(max_length=254, unique=true) address = models.charfield(max_length=255, null=false, blank=false) city = models.charfield(max_length=254, null=false, blank=false) active = models.booleanfield(default=1) = models.textfield() class meta: abstract = true and have 3 other models different fields , onetoone relation user model class manger(siteuser): manger = models.onetoonefield(settings.auth_user_model) manager_licsences_number = models.integerfield() class buyer(siteuser): buyer = models.onetoonefield(settings.auth_user_mo

ios - Creating shortcut for the app crashes on previous version -

i've created shortcutitem in app , when run in ios 9.2 works fine. when open app has ios 8.1 crashes. thread 1:exc_bad_access (code=1, address=0x0) how shortcutitem created if create shortcutitem icon , title dynamically after (launchoption == nil) return yes phone shows shortcutitems then?(because createshortcutitem not called should not show think.) able open shortcutitem once opened app opened , minimized though shortcutitems , icons not called in didfinishlaunchingwithoptions . am getting crashes in ios 8.1 @ line shortcutitem = [launchoptions objectforkeyedsubscript:uiapplicationlaunchoptionsshortcutitemkey]; so returning if launchoptions == nil fix crash. below code using in app using shortcut. created in main app i've modified names little bit example. how handle shortcut not supported on ios ( 8.0) or devices. want app support both ios8 , greater versions. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(ns

java - Zooming a view - not from drawable -

hi , thank in advance. i trying create onclick zoom animation image in imageview. i working example here android developer. which works great..and looking for. however, image expands seems come drawable folder. the picture want expanded created user, via camera, , stored in application folder. this how call picture , set imageview use: contextwrapper cw = new contextwrapper(getapplicationcontext()); file directory = cw.getdir("imagedir", context.mode_private); final file mypath=new file(directory,"pic_"+filename+".jpg"); loadimagefromstorage(mypath.tostring()); private void loadimagefromstorage(string path) { try { file f=new file(path); bitmap b = bitmapfactory.decodestream(new fileinputstream(f)); imageview img=(imageview)findviewbyid(r.id.imageview7); img.setimagebitmap(b); } catch (filenotfoundexception e) { e.printstacktrace(); } } and here relevant portion

http - Basic authentication option in apache web server is not working? -

i tried configure basic authentication website locally .but not applied site . my httpd.conf <virtualhost 192.168.2.5:80> documentroot /var/www/html/black-socks servername www.black-socks.com <directory "/var/www/html/black-socks"> order deny,allow allow authtype basic authname blacksocks-login authuserfile "/etc/httpd/conf/blacksocks-users" require validuser </directory> authuserfile is exist @ /etc/httpd/conf/blacksocks-users" , site html pages exist @ /etc/httpd/conf/blacksocks-users location. fine while accessing site not asking authorization <virtualhost 192.168.2.5:80> documentroot /var/www/html/black-socks servername www.black-socks.com <directory "/var/www/html/black-socks"> allow ram authtype basic authname blacksocks-login authuserfile "/etc/http

php - How can I use &#39; without slash? -

i want post input box have single quote inside php file.i've used ' sends backslashes: <input type="hidden" name="legal_natural" value="$store_info[&#39;legal_natural&#39;]"> result: $store_info[\'legal_natural\'] please tell me how can avoid backslashes when post ' php file? see : so question here's answer question: assume want send $content variable instead of stripping backslashes, consider use urlencode() instead of rawurlencode() . also, can use function once $content variable. $content = urlencode($content); update: both urlencode , rawurlencode may not fit case. why don't send out $content without url encode? how send our query string? if using curl, not need encode parameters.

Installer built with Install4j - Arrow keys cannot be used to navigate across buttons during install -

we have enterprise product installer built using install4j. issue have arrow keys cannot used move across buttons on install screens ("next", "back", "cancel" etc.) general standard (i looked @ few software installers - postgresql, git shell etc) , these support moving across buttons using arrow keys. the install4j version using 5.1.11. have such support ? if yes, how, if no, there chance might have facility in future versions ? use alt + left , alt + right navigate between screens. left , right not work keyboard shortcuts, example when text field focused.

regex - Avoid <script> tag and alert { } through regular expression in java -

i want show message-1 "script tag , alert not allowed message" if regular expression matches <script> tag or alert () parenthesis. , show different message-2 "welcome" if there alert or script. show message-1 following condition: 1) <script> 2) < script > 3) < script > script 4) < script > alert 5) < script> alert ( ) 6) alert alert( ) 7) alert () script 8) alert < script > show message-2 following condition: 1) script script 2) alert alert 3) script alert 4) alert alert script script 5) alert script script i tried <\s*[script\s*\s*]+ | \s alert\s \(\s*(.*?)\). not satisfying condition. please me. regex: <\s*script\s*>|alert\s*\(\s*\) test private static void test(string input) { string regex = "<\\s*script\\s*>|alert\\s*\\(\\s*\\)"; pattern p = pattern.compile(regex); matcher m = p.matcher(input); if (m.find()) { system.out.println("#1 &q

ios - How to Call the Custom UIView from ViewController using Frame Size -

i want show customuiview viewcontroller .how call using frame?i getting confused in frame newbie. theme is,i want show loginviewkarnataka , usernamelabel in viewcontroller in y value 150. code viewcontroller.m loginviewkarnataka *loginview = [[loginviewkarnataka alloc]initwithframe:cgrectmake(0, 0, self.view.frame.size.width, 150)]; [self.view addsubview:loginview]; loginviewkarnataka(customuiview) -(instancetype)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; nslog(@"frame==>>%f",frame); if (self) { uilabel *usernamelabel = [[uilabel alloc]initwithframe:cgrectmake(20, 20, 100, 20)]; [usernamelabel settext:@"username"]; [usernamelabel settextcolor:[uicolor blackcolor]]; } } change viewcontroller code to loginviewkarnataka *loginview = [[loginviewkarnataka alloc]initwithframe:cgrectmake(0, 50, self.view.frame.size.width, 150)]; [self.view addsubview:loginview]; in loginviewkarnataka view -(instancety

facebook page tab - client doesn't appear in the drop down list when add page tab -

Image
i trying make facebook page tab client , following steps in following link: http://blog.hubspot.com/blog/tabid/6307/bid/26330/how-to-create-custom-tabs-for-facebook-business-pages.aspx edit: these steps: login in developer account choose "add new app" -> webpage input app display name , click "create app id" choose "add platform" in app dashboard -> settings, choose "page tab" input page content's link in "secure page tab url" field - https open browser , type [facebook_url]/dialog/pagetab?app_id=my_app_id&next=my_url, replace my_app_id app id find in setting, replace my_url link in step 5 then found stuck because there no option can choose in "facebook pages" list, shown in image below: then did 2 more steps: in dash board, go settings , input contact email in status , review menu, switch yes on "do want make app , live features available general public?" tried again fac

java - StringBuilder() vs StringBuilder(null) vs StringBuilder("") -

public class testmystringbuilderii { public static void main(string[] args) { stringbuilder sb = new stringbuilder("hello"); stringbuilder sb1 = new stringbuilder("world"); stringbuilder sb2 = new stringbuilder(); //stringbuilder sb3 = new stringbuilder(null); stringbuilder sb4 = new stringbuilder(""); system.out.println(sb); system.out.println(sb.length()); system.out.println(sb.append(sb1)); system.out.println(sb.append(sb2)); //system.out.println(sb.append(sb3)); } } the sb3 = new stringbuilder(null) results in nullpointerexception. now, difference between stringbuilder(), stringbuilder(""), , stringbuilder(null)? a) system.out.println(sb2); printing empty space when actual characters ("null") expected appended (according abstaractstringclass definition) - why? b) system.out.println(sb2.length()); printing 0, because sb not "null" (meaning thing/type length of zero?)

iphone - local notification handling -

i trying crack way local notification work. i wrote line in order present notification scheduled: - (void)application:(uiapplication *)application didreceivelocalnotification:(uilocalnotification *)notification{ [[uiapplication sharedapplication] presentlocalnotificationnow:notification]; } the issue runs endless number of times. if write else runs 1 time, understood line should pop message of notification. can shed light? thanks, presentlocalnotificationnow triggering didreceivelocalnotification in turn calling presentlocalnotificationnow ... end endless loop.

ios - Swift: Adding Headers to my REST POST Request -

i still learning swift , trying make post request web service via new ios app written in swift. i need know how add 2 headers existing code. adding parameters correctly? what have far: let myurl = nsurl(string: "https://my-mobile-service.azure-mobile.net/api/login"); let request = nsmutableurlrequest(url:myurl!); request.httpmethod = "post"; // compose query string let poststring = "email=myemail@website.com&password=123"; request.httpbody = poststring.datausingencoding(nsutf8stringencoding); let task = nsurlsession.sharedsession().datataskwithrequest(request) { data, response, error in if error != nil { print("error=\(error)") return } print("response = \(response)") } task.resume() here headers need add request: x-zumo-application : 45634243542434 accept : application/json how attach these headers request? if use alamofire, should work, eases things choo

java - soap header issues <wsse:Security> header -

so, i've been given wsdl link through have consume soap services.as i'm running java code exception : exception in thread "main" javax.xml.ws.soap.soapfaultexception: error discovered processing header after trying testsuit soupui i'm receiving same error ns1:invalidsecurity error discovered processing <wsse:security> header i'm pretty new soap web services.can please guide me steps how add headers in java code authentication. thank :) okay have fixed issue had manually add custom headers request message. had detach previous header , append custom header request message. hope next time getting type of exception may this.

c++ - fftshift / ifftshift in terms of circshift -

and trying relate fftshift/ifftshift circular shift. n = 5 y = 0:n-1 x = [0 1 2 3 4] when fftshift(x), [3 4 0 1 2] when ifftshift(x), get [2 3 4 0 1] how relate fftshift/ifftshift circular shift? moving numbers in x in different directions? i need know i'm trying implement these 2 functions in terms of circular shift in c++, function have done. many thanks. after looking @ matlab codes, doesn't directly use circular shift, rather matlab syntax. say n = no. of elements to implement fftshift, circularshiftrightby = floor(n/2) to implement ifftshift, circularshiftrightby = ceil(n/2) being n/2, there difference between fftshift , ifftshift if n odd. where circular shift code is: template<typename ty> void circshift(ty *out, const ty *in, int xdim, int ydim, int xshift, int yshift) { (int =0; < xdim; i++) { int ii = (i + xshift) % xdim; if (ii<0) ii = xdim + ii; (int j = 0; j < ydim; j++) { int jj = (j

java - loadPolicyFile doesnt work in AS3 -

(im bad in english try good explain) i got client socket in as3 , server in java. in localhost, got no problem connect client , server. can exchange data no problem line : socket.connect("127.0.0.1", 2030); its ok, server can receive byte[] data , can read , write client no problem. but want past server "online" open port 2030 connection , 82 port, , try read crossdomain.xml autorized, : security.loadpolicyfile("http://90.20.233.143:82/crossdomain.xml"); socket.connect("http://90.20.233.143", 2030); now when im start connection ... have got problem security.loadpolicyfile im getting on java server : java.net.socketexception: connection reset and in client as3 (in french): connexion au serveur.... vous etes connecté au serveur avertissement :la balise non valide est ignorée pour le domaine ' http://90.20.233.143 ' dans le fichier de régulation présent à http://90.20.233.143:82/crossdomain.xml so

ajax - Rails remote form submitting duplicate form data -

Image
when submit remote form in rails, form post duplicate data, though if manually serialize form using jquery shows there no duplicates. causing this? *normally wouldn't problem, 1 of form data array, result there duplicate value in submitted array. result chrome's network inspector result jquery update here gist of form (removing html markups): <% @order.available_payment_methods.each |method| %> <%= radio_button_tag "order[payments_attributes][][payment_method_id]", method.id, method == @order.available_payment_methods.first %> <%= spree.t(method.name, :scope => :payment_methods, :default => method.name) %> <%= render :partial => "spree/checkout/payment/#{method.method_type}", :locals => { :payment_method => method } %> <% end %> # partial <% param_prefix = "payment_source[#{payment_method.id}]" %> <%= label_tag "name_on_card_#{payment_method.id}"

java - ChoiceBox not setting ObservableList in JavaFX -

i have choicebox in javafx application named choiceboxpizza. in controller declare with: @fxml private choicebox choiceboxpizza; my function contains test data is: private void fillchoiceboxpizza(){ try { list<string> list = new arraylist<string>(); list.add("pizza a"); list.add("pizza b"); list.add("pizza c"); observablelist oblist = fxcollections.observablelist(list); choiceboxpizza = new choicebox<>(oblist); } catch (exception e) { // todo auto-generated catch block system.out.println(e.tostring()); } } so should filled list . strange thing is, not exception , choicebox after call of method still empty. is there mistake in logic? replace line: choiceboxpizza = new choicebox<>(oblist); with one, should work: choiceboxpizza.setitems(oblist) you should not initialize element declared in .fxml file. here more broader expla

javascript - How to make sure that execution of a sync function happens after 3 asynchronous functions are completely done -

how make sure self.loadable() executed after 3 asynchronous requests complete. ??? var imghtml = "<span class='pull-right' style='padding-right:25px'><img alt='track' src='app/images/icons/track.png'><img alt='expand' src='app/images/icons/expand.png'></span>"; var request1 = {}; if(self.serviceid != null) request1.healthissue = {id:self.serviceid}; request1.location = {id:self.locationid}; request1.time = {id:header.defaultduration().value}; request1.hospital = {id:header.defaulthospital().value}; request1.query = {groupname:'speciality', dimension:'visits', viewby:'marketshare'}; console.log(request1); server.fetchdata(request1).done(function(data){ console.log('the specialty marketshares : '); console.log(data);

ember.js - Is there an EmberJS addon that runs the app in a try/catch and externally logs unhandled errors? -

i'd have system crashlytics can monitor unhandled errors users encounter. not ember plugin/addon, sentry provides you're looking for: https://getsentry.com/for/ember/ i'm sure there other libs/providers out there. quick google query takes me here: https://www.npmjs.com/package/ember-cli-airbrake

php - Change the integer time to date format in Grocery CRUD -

the view customer action in example given link shows details regarding customer.now among details have field time shows in int format. i need change int(1443198514) proper php date format(25 sep 2015 21:58:34). how that. relevant appreciated. unix timestamp date time $timestamp=1333699439; $today = date("f j, y, g:i a",$timestamp); // march 10, 2001, 5:16 pm $today = date("m.d.y",$timestamp); // 03.10.01 $today = date("j, n, y",$timestamp); // 10, 3, 2001 $today = date("ymd",$timestamp); // 20010310 $today = date('h-i-s, j-m-y, w day',$timestamp); // 05-16-18, 10-03-01, 1631 1618 6 satpm01 $today = date("y-m-d\th:i:s\z", $timestamp);

javascript - Cross product in underscore.js? -

is there function built-in underscore give "cross product" of 2 arrays? i have implemented cross-product this, nice if there built-in function -- domain = []; _.each(x, function(x1) { _.each(y, function(y1) { domain.push([x1,y1]); }); }); you can use _.mixin extend underscore own function.

java - Extend a JDOM Document -

for project @ university, need parse gml file. gml files xml based use jdom2 parse it. fit purposes, extended org.jdom2.document so: package datenbank; import java.io.file; // more imports public class gmldatei extends org.jdom2.document { public void saveasfile() { // ... } public gmlknoten getrootelement(){ return (gmlknoten) this.getdocument().getrootelement(); } public void setrootelement(gmlknoten root){ this.getdocument().setrootelement(root); } } i extended org.jdom2.element , named subclass gmlknoten not matter question. when testing, try load gml file. when using native document , element classes, loads fine, when using subclasses, following scenario: i load file using: saxbuilder saxbuilder = new saxbuilder(); file inputfile = new file("gml/roads_munich_route_lines.gml"); gmldatei document = null; arraylist<string> types = new arraylist<string>(); try { document = (gmldatei) saxbuil

ios - Why I get multiple UILocalNotifications in Swift? -

this function: func sendnotificationevery() { print("hey!") notification.alertbody = "message here" // text displayed in notification notification.firedate = nsdate() // right (when notification fired) notification.soundname = uilocalnotificationdefaultsoundname // play default sound notification.repeatinterval = nscalendarunit.minute // line defines interval @ notification repeated notification.applicationiconbadgenumber = 1 uiapplication.sharedapplication().schedulelocalnotification(notification) } and call here: override func viewwilldisappear(animated: bool) { sendnotificationevery() } so, issue is: when close app send 3-4 notifications instead of 1. how can fix issue? , want know, why happens? first of all, imagine requirement "while closing app have show notification". as per this, instead of writing above code in viewwilldisappear , write in appdelegate class, - (void)applicationdidenterbackg

android - Warning:Gradle version 2.10 is required. Current version is 2.8 -

for error tried 2 ways: 1)changed settings > builds,execution,deployment > build tools > gradle >gradle home path gradle-2.8-all.zip gradle-2.10-all.zip--- not worked 2)edited project\gradle\wrapper\gradle-wrapper.properties files field distributionurl distributionurl=https://services.gradle.org/distributions/gradle-2.8-all.zip distributionurl=https://services.gradle.org/distributions/gradle-2.10-all.zip--- no luck! still getting above error. other ways??? p.s: each time have done sync & rebuild project error occuring again download latest gradle-2.10-all.zip from http://gradle.org/gradle-download/ download complete distribution link open in android studio file ->settings ->gradle open path , paste downloaded zip folder gradle-2.10 in folder change gradle 2.8 gradle 2.10 in file ->settings ->gradle

spinner - How can I use Custom Loader or Progress View ROKU -

i want create custom spinner in roku app netflix.how can implement it.please guide me possible. if you're doing scene graph, easy way use class: https://sdkdocs.roku.com/display/sdkdoc/busyspinner otherwise, you'd have use 2d api, hassle.

algorithm - Find vertex at distance d -

i have tree n vertices. want design algorithm answer queries. given vertex v , integer d, want find vertex @ distance d v. if there more 1 vertex @ distance d output any. know how brute-force. tried idea similar lca finding algorithm (calculating ancestors @ distance 1, 2, 4, 8...), without result. i have many queries, 10^6, answer them in o(1) or o(log n) time this approach work compute centroid of longest path in tree. that, use depth-first search find vertex x max of vertex depths in tree rooted @ x minimal compute depth of vertices in tree rooted @ x using simple tree traversal group queries index of connected component query fall if x removed iterate on queries component. query (v, d). if depth(v) <= d, can use d-th ancestor of v answer, using standard approach in o(log n). otherwise, check if there solution vertex w path(v, w) crossing x , dist(v, w) = d looking depth d - depth(v) in 1 of other components (e.g. in o(1) via hashing) this works because i

android - ArrayAdapter is null even after getting a string array as a parameter -

i'm working on sunshine app in developing android app course udacity. stuck in lesson 2. i've listed down mainactivity.java contains listview populated network call in asynctask inner class in mainactivity.java. application crashes, due null pointer exception, array adapter null. i've tried debugging, , weekforecast (i.e., arraylist stores parsed data, , parameter creation of arrayadapter) have valid parsed data. in advance. public class mainactivity extends appcompatactivity { listview listview; arrayadapter<string> arrayadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); listview=(listview)findviewbyid(r.id.listview_forecast); gettingweatherfromnetwork gettingweatherfromnetwork = new gettingweatherfromnetwork(); gettingweatherfromnetwork.execute("94043"); listview.setadapter(arrayadapter); } @override public boolean oncreateoptio

c# - Asp.Net Web API is not receiving Post data from angular -

please me out. i want pass string post method of webapi controller using $http method.but getting null string @ controller side. here client side code. $http({ url: 'http://localhost/mywebapi/api/home', method: 'post', headers: { 'content-type': 'application/json' }, data: json.stringify({name: $scope.newproduct}) }).success(function (data, status, headers, config) { $scope.products = data; $scope.newproduct = ""; console.log(data); }) .error(function (data, status, headers, config) { console.log(data); }); and here webapi controller [httppost] public ihttpactionresult post([frombody]string newproduct) { var db = new mvcentities(); db.products.add(new product() { productname = newproduct }); db.savechanges(); var products = db.products.tolist(); return ok();

emacs - Problems with XEmacs Init (init.el) on Windows 7 -

i told work on windows system.... now use mature texteditor emacs. downloaded , installed xemacs (21.4.22). xemacs ist starting, behaves strange. ha no org-mode, can´t go threw proxy internet, updating or installing packaes. therefore, tried configure proxy in windows-directory. xemacs not able save init-el file in home-path/.xemacs, although file there (xemacs claims "no such file or directory"). user (me) has permissions save file, can "notepad" instance. but cant figure out, wat going on, xemacs not able save file in .xemacs directory.

c# - Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' -

Image
i'm using visual studio 2015 community edition, , i've created asp.net mvc 5 project. when open view ( index of home or other), shows first 3 lines of page underlined red syntax issue. here error: encountered unexpected error when attempting resolve tag helper directive '@addtaghelper' value 'microsoft.aspnet.mvc.razor.taghelpers.urlresolutiontaghelper, microsoft.aspnet.mvc.razor'. error: object reference not set instance of object the screenshot: when build project, build successfully. when run it, shows lot of errors, runs application. the type or namespace name 'mvc' not exist in namespace 'microsoft.aspnet' (are missing assembly reference?) and '_page_views_home_index_cshtml.executeasync()': no suitable method found override how can rid of this? here's how fixed issue: first, reset visual studio component cache closing visual studio , deleting folder: c:\users\[usernam

forms - attachment in a mail php -

good evening all, writing because have problems attach file loaded using form email. did not understand if have save before attaching folder or not .... code, mail arrives, without attachment. tell me wrong? $allegato=$_files['userfile']['tmp_name']; $allegato_name=$_files['userfile']['name']; $allegato_tipo=$_files['userfile']['type']; $uploaddir = '/uploads/'; $uploadfile = $uploaddir . basename($_files['userfile']['name']); $headers = 'from: '.$email.'' . "\r\n" . 'reply-to: pir.stefania@tiscali.it' . "\r\n" . 'x-mailer: php/' . phpversion(); ; if ($_files["userfile"]["error"] > 0){ echo "return code: " . $_files["userfile"]["error"] . "<br>"; }else{ if (file_exists("uploads/" . $_files["userfile"]["name"])){

c# - Return SQL to Generic List Automatically -

i have function connects database , extracts data. the data returned expando object. i convert expando object class, linq statement on dynamic line however, wondering if had class of fields in sql code, there way system automatically map each field in class? i.e. public list<clientall> fulltableclients() { const string abstractstatement =@"select * client clino = '0000001'"; var sqlstatement = new sqlstatements(abstractstatement, _reportingbackoffice.generatetables); var data = _reportingbackoffice.executequery(sqlstatement); var name = (from dynamic line in dataarray select new clientall() { clientnumber = line.????? //normally write line.clientnumber }).tolist(); return name; } as can see above, need way reference field name in class , use variable when assign line? thanks, david if have linq2sql datacontext can write: const string abstractsta

ruby - How can I prevent a positional argument from being expanded into keyword arguments? -

i'd have method accepts hash , optional keyword argument. tried defining method this: def foo_of_thing_plus_amount(thing, amount: 10) thing[:foo] + amount end when invoke method keyword argument, works expect: my_thing = {foo: 1, bar: 2} foo_of_thing_plus_amount(my_thing, amount: 20) # => 21 when leave out keyword argument, however, hash gets eaten: foo_of_thing_plus_amount(my_thing) # => argumenterror: unknown keywords: foo, bar how can prevent happening? there such thing anti-splat? this bug fixed in ruby 2.0.0-p247, see this issue .

php - PHPMailer smtp connect() failed on ovh server -

Image
i'm using phpmailer send daily emailing (max 100 emails), script works fine on local, when uploaded server (hosted on ovh) blocks , generate error after sending average of 20 emails smtp connect() failed https://github.com/phpmailer/phpmailer/wiki/troubleshooting i contacted ovh , sad there no problems email adresse think bug on code, here code: $m = new phpmailer; $mail = new mailing(); $admin = new administrateur(); $m->issmtp(); $m->ishtml(true); $m->smtpauth = true; $m->smtpdebug = 0; $m->smtpkeepalive = true; $m->host = 'ssl0.ovh.net'; $m->username = 'exemple@exemple.com'; $m->password = 'xxxxxxxxxxx'; $m->smtpsecure = 'ssl'; $m->port = "465"; $m->charset = 'utf-8'; $m->from = 'exemple@exemple.com'; $m->fromname = 'chantier tn'; $m->addreplyto('exemple@exemple.com', 'reply adress'); $m->subject = 'alerte quotidienne'; $error = fals

angularjs - Angular - Get data into ng-Model from object in controller -

i not able put data ng-model in view object in controller. view1 : <input type="text" class="user-input" name="profile.firstname" ng-model="profile.firstname" ng-minlength="2" required pattern=".{2,}" placeholder="e.g. anvika" title="please enter atleast 2 characters"> when click button in view2, fires function (say function 'test'). view2 <input type="submit" ng-click="register.test()" ui-sref="doctorregister" value="profile"> controller: var app = angular.module('app'); app.controller('registercontroller', ['$scope', 'tempdatastorageservice', function ($scope, tempdatastorageservice) { var register = this; register.doctor = {}; register.test = function () { register.refreshprofile = tempdatastorageservice.get(register.doctor.profile); //console.log(register.refreshprofile); var = reg