Posts

Showing posts from January, 2012

javascript - How do I make the name of my object dynamic -

i creating new objects in array , want able assign dynamic name can access easier. below sample of looking do. want value 'iwantthisdynamic' able variable can name whatever choose when push array. i using javascript. ideas? in advance! myarray = []; myarray.push({iwantthisdynamic:{'color' : 'red', 'image':'3.jpg'}}); you can't arrays since array items accessed index, not key. that's objects for. myobj = {}; myobj.iwantthisdynamic = {'color' : 'red', 'image':'3.jpg'}; or if name dynamic: var dynname = 'dynamic'; myobj[dynname] = 1;

android - Sqlite order by the many correct where statement -

how can order sqlite query clause. for example: -------------------------------------- | id | body | -------------------------------------- | 1 |the boy going bed | -------------------------------------- | 2 |the boy child | -------------------------------------- | 3 |the boy playing computer| and search input is: "the boy going bed" so sql query be. select * data body '%the%' or '%boy%' or '%is%' or '%going%' or '%to%' or '%bed%' i want the id 1 first because have many correct clause. in sqlite, result of boolean expression 0 or 1, can add these comparison expressions: select * data body '%the%' or body '%boy%' or body '%is%' or body '%going%' or body '%to%' or body '%bed%' order (body '%the%' ) + (body '%boy%' ) + (body '%is%' ) +

javascript - Unable to add spaces to input text -

hi have following code, know how can modify user can add spaces? jsfiddle i used code , modified here: $('#text').keyup(function(e, w) { $("#prev").html($(this).val()); var txtwidth = $( "#text-preview" ).width(); $( "#textwidth" ).text( "approx. width: " + txtwidth + " px." ); }).keypress(function(e) { return /[a-z0-9.-]/i.test(string.fromcharcode(e.which)); }); html: <!--display user input--> <span id="text-preview"><p id="prev" class="form_result"></p></span> <!--display width--> <p id="textwidth"></p> <label class="sign-text">enter text <input type="text" name="text" id="

Kubernetes set-up on ubuntu on Google compute -

can 1 me understanding error getting while trying set-up kubernetes. trying follow url , run command $ curl -ss https://get.k8s.io | bash error: (gcloud.components.update) component manager disabled installation i running command on google compute ubuntu machine. appreciate help adding complete error ( ubunut 15.4), after full blown google sdk installation ............. unpacking kubernetes release v1.0.3 creating kubernetes on gce... starting cluster using provider: gce ... calling verify-prereqs cannot perform action because component manager has been disabled installation. if latest version of google cloud sdk, please see our main download page at: https://developers.google.com/cloud/sdk/ error: (gcloud.components.update) component manager disabled installation cannot perform action because component manager has been disabled installation. if latest version of google cloud sdk, please see our main download page at: https://developers.google.com/cloud/sdk/ error:

python - How to make a quick db select of the range of latitude and longitude in Django? -

there table: class place(models.model): user = models.manytomanyfield(settings.auth_user_model, related_name='places_user') title = models.charfield(max_length=250) address = models.charfield(max_length=500) latitude = models.floatfield() longitude = models.floatfield() image = models.imagefield(upload_to='place-images') def __unicode__(self): return self.title please tell me how make quick select of range of latitudes , longitudes. for example, there 100,000 records. need choose records in longitude 101.25..117.39 , latitude 223.46..232.55. i think use postgres database. in result think use postgis + geodjango. details: geodjango blog page . use range query: place.objects.filter( longitude__range=(101.25, 117.39), latitude__range=(223.46, 232.55), )

setUserVisibleHint with Fragments for android -

im using 3 fragments in viewpager adapter . loading data parse(parse.com) , displaying them in recycler views. following code causing app crash. understanding when mainactivity loads, first fragment ie, gets viewed user setuservisiblehint function gets called , in v.findviewbyid code causes null pointer exception since setcontentview hasnt/ may not been called. proof if add 1sec delay setuservisisblehint code works properly. now want add server pull requests using parse, add data in list adapter , populate recyclerview after user views page so 1) should add code in setuservisisblehint , add 0.5secc delay gets executed after setcontentview called ensuring dont null pointer exception error or 2) there better way/ other functions can use achieve same? public class newsfeed extends fragment { linearlayoutmanager mlayoutmanager; boolean _arelecturesloaded=false; view v; progressbar bar; public newsfeed() { // required empty

css - @font-face not loading fonts -

my webfont isn't showing up. here's @font-face declaration. copypasted fontsquirrel. directories relative css file location. @font-face{ font-family: "dejavu sans light"; src: url("../fonts/dejavusans-extralight-webfont.eot"); src: url("../fonts/dejavusans-extralight-webfont.eot?iefix") format('eot'), url("../fonts/dejavusans-extralight-webfont.woff") format('woff'), url("../fonts/dejavusans-extralight-webfont.ttf") format('truetype'), url("../fonts/dejavusans-extralight-webfont.svg#webfont") format('svg'); } css: html { font-family:"dejavu sans light", arial, sans-serif; } firebug's net panel says font request returning response code 200, it's still showing default font. edit: tested in chrome , ie, , it's not working there either.

image - How to decode JPEG XR files in memory using Python? -

i'm using python 3 process file produced microscope, collection of thousands of jpeg xr compressed images. need read of them memory. i'm reading data in binary mode, saving them in .jxr file , call jxrdecapp.exe convert tiff , read memory. apparently major bottleneck performance because involves lot of file read , write. from gather, imagemagick delegates task jxrdecapp.exe. using wand wouldn't help, either. right? then i'm wondering if there way decode jpeg xr in memory using python? thanks ! imageio ? it supports jpeg xr, , can read can read filenames, file objects, http, zipfiles, bytes, webcams.

glm - R: GLMM glmer vs glmmPQL -

what syntax in glmmpql multiple random effects? with glmer code looks like: fit<- glmer(a~b+c+ (1 | d)+ (1 | e), family = gaussian, data=data) how rewrite same exact thing using glmmpql ? i trying: fit<- glmmpql(a~b+c, random=c (~1 | d, ~1 | e), family = gaussian, data=data) but gives error. and major difference between glmer , glmmpql ? based on example provided, model glmmpql specified as: fit <- glmmpql(a ~ b + c, random = list(d = ~1, e = ~1), family = gaussian, data = data) afaik, major difference between glmer (which provided package lme4 ) , glmmpql (which relies on function lme , nlme pacakge) parameter estimation algorithm used in nlme not optimized dealing crossed random effects, associated sparse design matrix, while lme4 takes advantage of structure; see, e.g., pinheiro & bates, "mixed-effects models in s , s-plus", springer, 2000, pp. 163. further references on differences between lmer/glmer , lme usual: ht

ios - When to check if presenting viewController is of type if using autolayout -

this code using set constraints in viewdidload: if (self.presentingviewcontroller?.iskindofclass(gameviewcontroller) != nil) { print("huhu") self.bottomviewtobottomconstraint.constant = -367 self.bottomviewtohiddenbuttonconstraint.constant = 401 } else { self.bottomviewtobottomconstraint.constant = -200 self.bottomviewtohiddenbuttonconstraint.constant = 200 print("no presenting viewcontroller") } the message i'm getting no presenting viewcontroller. can see setting constraints animated differently, depending on class presenting viewcontroller. @ time known presenting view controller , right time set constraints? help as simple as: after add bottomview it's superview . try viewwillappear method: -(void)viewwillappear:(bool)animated { [super viewwillappear:animated]; // here }

javascript - Updating the limitTo value on a specific nested ngRepeat -

i'm new angularjs , having work on app has section of nested ngrepeats such below. <div class="title-bar" ng-repeat="ordertype in someobj.ordertypes"> <div class="inner-panel" ng-repeat="status in ordertype.statuses"> <p>{{status.name}}</p> <div class="order-list" ng-repeat="order in status.orders | limitto:orderfilterlimit"> <p>{{order.stuff}}</p> </div> <button ng-show="(status.orders.length > orderfilterlimit)" ng-click="loadmoreorderstolist()">load more</button> </div> </div> the status.orders list can quite large @ times limit it. when user wants view more data specific section (which enumerated status ) add 3 orderfilterlimit . problem when adding 3 every single .order-list in .inner-pannel element. there way can change orderfilerlimit variable based on id or c

javascript - How to do nested looping over many pages in CasperJS -

i don't have clue start this. need casperjs run through 15 different pages, each page runs through needs data 150 different locations need set cookie values. each location, need check data 5 different dates. any 1 of these seems pretty straight forward, trying 3 happen confusing me. i tried set way: for(iterate through urls){ for(iterate through locations){ for(iterate through dates){ phantom.addcookie({ // cookie data here based on location , date }); casper.start(url) .then(function(){ // stuff here }) .run(); } } } essentially loop through everything, load page based on last link, @ last location, on last date. every other location gets skipped. there easier way this? perhaps better, there way tell javascript loop wait casper finish doing needs before jumping next loop iteration? i'm happy provide more details if needed. tried simplify process best can without cutting out needed info.

php - Making a module change a default behavior without using overrides in Prestashop -

i want ps module change default behavior without using overrides. want add element ".tpl" file. is possible? you can try hang functionality 1 of existing hooks. if none of them works case, you'll have create own hook , add call theme tpl.

How Do I Save Data in a Java Windows App? -

i'm creating simple windows app using java allows users save passwords , usernames websites of choice. how make when user logs off app, information user posted in app saved? of data being saved arrays , linked lists, if helps. edit: know i/o , saving data files. i'm looking solution if possible. websites usernames , passwords should never saved in app or in machine. it's not secure. in response comment:- once user go offline, need store username , passwords. this, need database data persist, , available when user login next time. store data in encrypted format highly sensitive. can explore h2 database engine , in-memory database , support encryption.

ruby on rails - heroku free tier add worker -

i'm using heroku's free tier , trying set worker process delayed_jobs. according docs have access worker. can run worker process running heroku run rake jobs:work , 1 off process. i've looked @ heroku's delayed jobs docs , when trying run heroku ps:scale worker=1 following message scaling dynos... failed ! please verify account in order change resources (please enter credit card) more information, see https://devcenter.heroku.com/categories/billing verify @ https://heroku.com/verify how can scale worker dyno free plan? need enter in credit card? from heroku docs credit card information not required free apps without add-ons. becomes requirement once wish own more 5 apps @ time, or use add-ons other postgresql:dev or pgbackups:plus –– if add-ons free. it's scaling app add worker considered add-on, therefore required validate account.

javascript - Styling a jQuery Plug-In (ClassyCountdown) -

i using countdown site: http://www.class.pm/files/jquery/classycountdown/ now want style countdown, don´t know how. want edit font, color, thickness of line , scale whole countdown. how style it? edit: working link: http://www.html.it/wp-content/uploads/script/demo/a/51105/demo.html edit 2: figured out how scale whole countdown. used width of id , resized automatically. #countdown-container { width: 500px; } but how change font, color , thickness of line? i figured out how scale whole countdown. used width of id , resized automatically. #countdown-container { width: 500px; }

Terminate http request via header error code return or JSON response -

how can call multiple error return functions handlefunc? i have found similar need in link: golang: terminating or aborting http request . so, in cases, need return error response http error code, below (code taken link above): http.handlefunc("/", func(w http.responsewriter, r *http.request) { // examine incoming params if !ok { http.error(w, `invalid input params!`, http.statusbadrequest) return } // normal api serving }) however, in cases need return json response web client: http.handlefunc("/", func(w http.responsewriter, r *http.request) { // examine incoming params if !ok { w.header().set("content-type", "application/json") w.writeheader(http.statusbadrequest) str := `{"result":"","error":"no valide var"}` fmt.fprint(w, str) return } // normal api serving }) question is: want place error handling part

python - Selecting elements from a .dat file according to an assigned value -

i have .dat file of form: 1.5699000000000001 -10.230000000000000 3 1.5978000000000001 -10.550000000000001 3 1.2388999999999999 -9.7100000000000009 3 1.9540999999999999 -12.910000000000000 4 1.7915000000000001 -12.539999999999999 4 1.7547999999999999 -10.740000000000000 4 1.8927000000000000 -10.800000000000001 4 1.9222999999999999 -10.869999999999999 4 1.9047000000000001 -11.770000000000000 4 1.8488000000000000 -12.279999999999999 4 1.6536000000000000 -10.690000000000000 3 1.7059000000000000 -11.410000000000000 4 1.7834000000000001 -12.250000000000000 4 1.4136000000000000 -9.7699999999999996 3 1.8093999999999999 -10.990000000000000

ios - Filter array of custom objects in Swift -

i'm trying filter array of custom objects in swift subset of data has properties want isolate. code follows. func generatesubset( datapool : [customobject]) -> [customobject]? { let subsetdata = datapool.filter{(includeelement:customobject)-> bool in return contains(includeelement.position, "teacher") } return subsetdata } my custom object follows: class customobject : { var position : string? init(){ position = "" } } however error xcode throws me when trying compile code is: cannot invoke 'filter' argument list of type [customobject] -> bool i'm using swift 1.2 , can't seem figure out i'm doing wrong. appreciated. in swift 1.2, filter global function, can't datapool.filter(...) . (in swift 2, work.) furthermore, contains can't used strings that. recommend using rangeofstring: method nsstring: let

CloudKit Authentication Returning 404 -

i'm working on web app grabs data ios app using cloudkit. part of application, must login using appleid. however, when try login, i'm getting 404. request following url: https://api.apple-cloudkit.com/1/[mycontainer]/development/users/current?ckapitoken=[mytoken] i object looks this: { "uuid" : "123-abc", "servererrorcode" : "authentication_required", "reason" : "request needs authorization", "redirecturl" : "https://idmsa.apple.com/idmswebauth/auth2?oauth_token=oattkn49471611-really-long-alpha-code" } however, when redirect user "redirecturl" parameter, i'm getting blank 404 page. inspecting page, idmsa.apple.com loads, when javascript on page requests signin?widgetkey={key} gets 404. update: i'm not sure if helps, https://idmsa.apple.com/idmswebauth/auth2?oauth_token=[token] loads fine. however, page uses javascript load https://idmsa.apple.com/appleau

multithreading - Why this python multi-thread approach take more time than single thread to solve the same task? -

why python multi-thread approach take more time single thread solve same problem? note computer multi-core processor cpu. i wrote same code in both ways , make comparison. surprisingly single thread way faster! have thoughts? #!/usr/bin/python l = [1,2,3,4,5,7,8,9,10] def gen(index,value): if index==len(l): return 1 count=0 in range(len(value)+1): count+=gen(index+1,value[:i]+[l[index]]+value[i:]) return count #single thread approach print gen(1,[1]) #this takes 480ms run! #multi-thread approach threading import thread def t1_start(): global pointer1 pointer1=gen(2,[2,1]) def t2_start(): global pointer2 pointer1=gen(2,[1,2]) pointer1=0 pointer2=0 t1=thread(target=t1_start,args=()) t2=thread(target=t2_start,args=()) t1.start() t2.start() t1.join() t2.join() #print pointer1+pointer2 #this takes 650ms run! i've had problem in java. users suggested overhead, creation of threads costs, slowing down much, took lo

jquery - Mouse drag to scroll content -

i'm working on gallery drag scroll trough images in gallery, similar this . the drag detection working fine, don't sliding of content work properly. detects dragging , manages set proper position, jumps beginning when drag again. this how function runs on drag looks like: dragcontent: function(e) { var delta = e.pagex - project.dragstartx; project.isie ? $('#gallery-content').css("margin-left", delta) : $('#gallery-content').css("translatex", delta); }, have @ jsfiddle have recreated problem. i think need save position content stops , somehow start position on next drag detected. want smooth easing example, still rolls bit on "mouseup". i'm hoping want share thoughts on how solve without using plugins. you need store current state of slider. right now, you're correctly calculating delta, distance mouse (or pointer) has traveled. you're setting delta margin, meaning start @ 0. i mo

Parse Twitter authentication log out does not delete the token -

i trying let users of android app log in via twitter account , ran following problem. using parse store data , users' information. when user logs in , logs out app via twitter, there window message "authorize app use account", app still associated particular twitter user. problem there no window email , password entries, when user logs out via twitter (parseuser.logout()). how can unlink app current user , present new log in window. thank you!

windows - Reading blacklist from a text file in C++ -

i need driver read (line line) programs going blacklisted. _t("bannedfile.exe") need put blacklisted program. how can make _tcscmp read text file, line line? (it makes comparison between host program loads driver, , blacklisted one) bool processblacklist() { tchar modulename[max_path]; getmodulefilename(null, modulename, max_path); pathstrippath(modulename); if (_tcscmp(modulename, _t("bannedfile.exe")) != 1) { return 0; } else { return 0x2; } } can't done way. you should able use use getline read file line line , pass lines _tcscmp. should work this: wchar_t const name[] = l"bannedfile.exe"; std::wifstream file(name); std::wstring line; while (std::getline(file, line) { if (_tcscmp(modulename, line.c_str()) == 0) { return true; //module in list } } return false; // module not in list lacking copy of vs test @ moment. if run unicode parsing problems because fi

Google Docs =Filter() will randomly show "N/A" till I erase the function and paste it back in -

i've been having consistent issue every =filter() function on spreadsheets stop working, display "n/a" "no matches found in filter evaluation". filtering data same sheet, not importing it. i have copy function, delete it, hit enter apply changes cell, paste in , hit enter apply function again. after work expected. this happens no rhyme or reason, , affects worksheets in document. how prevent this? there way automatically fix without copy/pasting functions dozens of times on regular basis? edit: function example =filter(organize!f2:k1000, organize!d2:d1000 = b6, organize!c2:c1000 =a6, (organize!e2:e1000 = "doug") + (organize!e2:e1000 = "rach owes doug")+ (organize!e2:e1000 = "both")+ (organize!e2:e1000 = "rach owes doug split")) this shows "n/a" "no matches found in filter evaluation" till delete , paste in.

android - ScrollView doesn't scroll in layout? -

i have in order relativelayout / scrollview / relative layout / relative layout , inside last relative layout have 2 linear layouts. don't know why happening. have same layout other activity , it's working. here xml code: <?xml version="1.0" encoding="utf-8"?> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" > <scrollview android:layout_width="match_parent" android:layout_height="4000dp" android:paddingbottom="5dp" android:paddingleft="5dp" android:paddingright="5dp" android:paddingtop="5dp" android:orientation="vertical" android:scrollbars="none" android:background="@drawable/ur

Root level domain google clouddns -

how make root level domain ( http://getdor.com ) redirect http://www.getdor.com/ ? domain managed google cloud dns. you try cname'ng explained below getdor.com 11.22.33.44 www.getdor.com cname getdor.com

data structures - Does using union-find in Kruskal's algorithm actually affect worst-case runtime? -

so i'm teaching myself graph algorithms, on kruskal's, , understand it's recommended use union-find checking whether adding edge creates cycle takes o(log v) time. practical purposes, see why you'd want to, strictly looking through big o notation, doing affect worst-case complexity? my reasoning: if instead of union find, did dfs check cycles, runtime o(e+v), , have perform v times runtime of o(v^2 + ve). it's more union find, o(v * logv), bulk of complexity of kruskal's comes deleting minimum element of priority queue e times, o(e * loge), big o answer. don't see space advantage either since union-find takes o(v) space , data structures need maintain find cycle using dfs. so overly long explanation simple question: using union-find in kruskal's algorithm affect worst-case runtime? and understand it's recommended use union-find checking whether adding edge creates cycle takes o(log v) time this isn't right. using union find

reflection - Getting method's function type from the MethodMirror instance in Scala -

assume have instance of methodmirror created method of object. mirror's fields can access return type , parameters of method. need obtain type method have function. here toy code example me explain, want achieve. i'm using scala 2.11.6. import scala.reflect.runtime.universe._ object forstackoverflow { object obj { def method(x:string, y:string):int = 0 def expectedrettype():((string, string) => int) = ??? } def main(args: array[string]) { val mirror:mirror = runtimemirror(getclass.getclassloader) val instancemirror = mirror.reflect(obj) val methodsymbol:methodsymbol = instancemirror.symbol.totype.decl(termname("method")).asmethod val methodmirror = instancemirror.reflectmethod(methodsymbol) println(methodmirror.symbol.returntype) println(methodmirror.symbol.paramlists(0).map { x => x.info.resulttype }.mkstring(", ")) val expectedsymbol:methodsymbol = instancemirror.symbol.totype.decl(termname(&quo

clojurescript - How to get cljsbuild to run BEFORE uberjar compiles a clojure app? -

i'm making isomorphic app in clojure / clojurescript / reagennt. due fact have dependency on clojurescript output js file server-side rendering, i'd file compiled before jar does. how do that? here's output of "lein uberjar" notice jar compiled first. clj file "nash.clj" needs run compiled server-side.js build: johns-macbook-pro:bfa-clojure johnkealy$ lein uberjar minifying assets... minifying: resources/public/css/site.min.css assets: site.css original size: 88983 compressed size: 73886 gzipped size: 13676 compiling bfa-clojure.api.auth compiling bfa-clojure.api.misc compiling bfa-clojure.api.photos compiling bfa-clojure.global compiling bfa-clojure.handler compiling bfa-clojure.nash compiling bfa-clojure.pages compiling bfa-clojure.server 2015-08-17 14:34:32.964:info::main: logging initialized @21242ms compiling clojurescript. compiling "resources/public/javascripts/server-side.js" ("src/cljs" "src/server-cljs" &

how to compile a code with if statement in make file in fortran? -

i using fortran code write code. using subroutine inside loop. , name of subroutine different various runs (i have written subroutines). whenever want run code different case, have change name of subroutine accordingly. don't want modify code again , again. want 2 write global code. can use subroutines "if statement" in code. in case not have modify code every time. in way if statement run @ each step. possible write code in way give value of parameter , code compiles subroutine want out loop or statement. or can using if statement in make file. you have few options. this doesn't fit question requests directly, having if statements picking right subroutine of negligible cost. using input file determines subroutine use way have 1 executable can handle multiple cases. there fortran preprocessors; using preprocessor such fpp right way have make compile code target particular subroutine. this great problem scripting language; if don't know language

Can Not Increase Android Emulator Internal Storage -

Image
i can't increase android emulator internal storage more 533 mb tried: edit disk.datapartition.size=1g in config.ini file change configuration on android virtual device manager screen shoot below. but android emulator internal storage still 533 mb setting emulator android studio 1.3.1 nexus 5 emulator profie target sdk 5.1.1 cpu x86_64 you can resolve resizing userdata.img file located on avd emulator folder: cd ~/.android/avd/youremulatorname e2fsck -f userdata-qemu.img rm userdata-qemu.* resize2fs userdata.img 1024m now start avd emulator again , you'll see it's storage increased. windows users can cygwin enabling "e2fsprogs" package on install/update. p.s.: must change 1024m wanted value of internal storage.

c++ - zmq::proxy example doesn't work () -

i learning how use lib zeromq friend advise me use personnal project. after reading documentation , planning how use lib project, began testing project code given documentation. test used this one . unfortunatly doesn't work. did minor modification test it. (i give exact code have on test, it's lot sorry without think doesn't make sense , it's impossible me :/ ). i changed nothing test given documentation, added output test , deleted poll in client (i thought probleme came here because blocking infinite loop thought there timeout). #include <vector> #include <thread> #include <memory> #include <functional> #include <zmq.h> #include <zmq.hpp> #include <zhelper.hpp> // our client task class. // connects server, , sends request once per second // collects responses arrive, , prints them out. // run several client tasks in parallel, each different random id. // atte

jquery - how to fix an element inside bootstrap modal with respect to bootstrap modal -

i want fix element inside bootstrap modal, position: fixed on scrolling moves modal. want stick @ place after modal scrolled. here jsfiddle . here see patate text has position: fixed css attribute if modal large moves it. how can fix text place stays @ position if modal scrolled. i had no luck this. please help. thanks. this might help. using grid inside modal separate fixed div rest of content. $('.launch-scroll').on('click', function(e) { $('#modal-scroll').modal({ show: true }); }); .modal { overflow: hidden; } .modal .modal-body { height: 500px; overflow: auto; } .modal .modal-fixed { position: fixed; background-color:red; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <link href="https://maxcdn.boot