Posts

Showing posts from July, 2013

python - packing selenium with py2exe -

i'm trying pack selenium py2exe howerever despite following instructions here python - trouble in building executable with setup.py being: from distutils.core import setup import py2exe setup( console=['planofcaremodified9gui.pyw'], options={ "py2exe":{ "skip_archive": true, "unbuffered": true, "optimize": 2 } } ) copying , pasting webdriver_prefs.json and webdriver.xpi dist directory instructed link above. still spits out this: filenotfounderror: [errno 2] no such file or directory: 'c:\\python34\\dist\\lib rary.zip\\selenium\\webdriver\\firefox\\webdriver_prefs.json' i have been searching on internet 2 days , still found nothing. closest came solution on link above. none of answers fixes issue. i on python 3.4 , using selenium 2.45.0 i've tried putting webdriver_prefs.json and webdriver.xpi inside library....

c++ - Boost Pointers as a means of an array -

i'm converting c code open-source, c++11 style compatible code, uses boost. (purposefully not used c++ shared ptr implementation) i've studied use of boost shared_ptrs vs unique_ptrs vs. raw pointers means of managing memory resources, based on intended ownership, etc. i'm getting confused though, @ different layers of abstraction @ raw pointers can used , whether semantics translate boost. i have templated class purposely composed of different structs make use of said structs. example: template <typename my_type> class : public base_a { ... typedef struct b { float* numbers; my_type* my_types; }; typedef struct c { b* b_types; }; } this i'm getting confused. pointers used reference contiguous blocks of memory, right? because pointers, can use [] operator index offset of reference memory, , in way pointers not used reference objects, arrays of types well. again, guess can class can pointers , data s...

javascript - Bootstrap Modal Does not work -

i trying make modal work wont work. this code: pastebin.com/es17dxkk i followed on bootstrap site wont want work. can me out? that's because bootstrap's javascript requires jquery loaded. add following line before import bootstrap javascript: <!-- javascript files --> <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

python - Your recommendation to reset a postgress database in heroku after CircleCI tests -

i using circle ci tests , pushing python application heroku in order run web gui tests on machine. what recommended way of filling heroku instance database content? i not think circle ci should access heroku instance or database directly? the heroku deploy hooks seem able call web hook. run command reset database. if you're using built-in heroku deployments, won't able this, e.g. if configuration looks this: deployment: staging: branch: master heroku: appname: foo-bar-123 you can instead configure deployment run several commands: deployment: production: branch: production commands: - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow" - git push git@heroku.com:foo-bar-123.git $circle_sha1:refs/heads/master - heroku run rake db:migrate --app foo-bar-123: timeout: 400 # if deploys take long time the comment two-bit alchemist command reset database. the a...

ios - Auto layout removing from superview doesn't update -

i'm trying make uilabel grow removing constraints via removefromsuperview. text field 1 removed. still doesn't let uilabel grow in width. have attached sample code here reference. on story board. here viewdidload method: self.label1.text = @"label 1"; self.label2.text = @"label 2"; self.textfield1.text = @"text field 1"; self.textfield2.text = @"text field 2"; [self.textfield1 removefromsuperview]; i don't want have iboutlet of constraints , update on code. i'm trying on storyboard once. i think label 2 depending on position textfield 1, , want label 2 grow occupy space of textfield 1 when remove textfield 1. however, since label 2 (say, 20 pixels right of textfield 1), when remove textfield 1, constraint removed (it invalid textfield 1 no longer exists!) , default 1 generated relative superview. there simple solution rather imperfect - instead of removing superview set width of textfield 1 0. see ...

how to install a toolbox to matlab if I do not have administrative authorization -

i plan install sbetoolbox matlab in pc not have administrative access. found https://www.youtube.com/watch?v=p6pzoa55q68 , other related links. since not have administrative access, not know started. can me please? many thanks. i don't know particular toolbox. in general: unpack toolbox folder (preserving paths!) of choosing, , add folder matlab path.

Clean undefined items in Numeric Array and sort it by javascript -

i have array created inside for loops below array of numbers contains undefined items & dont know right way remove undefined items , sort finely , see: 2426,3045,,1680,,,1323,,,,1311 after sorting , here first 2 items merged : 24263045,1680,,1323,,,1311,,,, here code: var textcontent = 'larg text content larg text content larg text content larg text content larg text content larg text content'; var words = 'content larg text'; var word = words.split(' '); for(var i=0;i<word.length;i++){ var kx=[]; kx[i] = textcontent.indexof(word[i]); function sortnumber(a,b) { return - b; } //trying sort var vk = kx.sort(sortnumber); document.write(vk); // returns // 24263045,1680,,1323,,,1311,,,, } how remove undefined items , sort be 1311,1323,1680,2426,3045 you can make use of filter() . var arr = [2426,3045,,1680,,,1323,,,,1311]; function test(array){ var arr = array.filter(function(item){ return item && item!=...

eclipse - Changing OS proxy settings using java -

can set/change proxy settings in windows 7 using java application? i trying use: public static void setproxy(string proxyurl, string proxyport){ system.getproperties().put("proxyset", "true"); system.getproperties().put("http.proxyhost", proxyurl); system.getproperties().put("http.proxyport", proxyport); } but after run settings doesn't changed , have same ip had before. even though of languages not allow (or) discourage change environment variables through program, can achieve jni in java using setenv() , using processbuilder() . but why want change every 1 program? instead change variables in program context setting proxy server effective program run time context. that's how applications should designed , programmed. here example, off top of head. public static void main(string[] args) throws exception { processbuilder processbuilder = new processbuilder("cmd.exe", "/c...

windows - How do I kill a task in batch? -

i having problems taskkill in batch, trying kill vbscript in sleep x amount of seconds. want kill task: http://i.imgur.com/nnvf1fh.png but somehow seem wrong, have no clue part of task have write in taskkill x thank in advance! this kill without knowing pid , kill all instances of wscript.exe . taskkill /f /im wscript.exe

automation - C# Get Value from ID when ID changes Slightly -

i trying value id changes every time. for example have : <img id="economy_item_#######_item_icon" alt="dual berettas | colony"> i trying retrieve "dual berettas | colony" have put #'s number changes every time. how can achieve this? any , appreciated. thanks you may use jquery attribute contains feature. https://api.jquery.com/attribute-contains-selector/ like this: var txt = $("img[id*='economy_item_']").attr('alt');

java - Immutable Objects & Updates -

if i'm using immutable class named name stores people's names, , wants change name shouldn't name updated (essentially delete old entry , insert new entry)? appears contradict definition (by annotation) of immutable updating entity ignored. should if immutable class stored in database needs updated? should not mapped @immutable though immutable class? the reference says: when entity read-only: hibernate does not dirty-check entity's simple properties or single-ended associations; hibernate not update simple properties or updatable single-ended associations; hibernate not update version of read-only entity if simple properties or single-ended updatable associations changed; and says: in ways, hibernate treats read-only entities same entities not read-only: hibernate cascades operations associations defined in entity mapping. hibernate updates version if entity has collection changes dirties entity; ...

Send only a few entries of JSON array -

is possible send entries of json array? i have json object defined following schema: "linegroup": { "type": "array", "description": "line group active", "items": { "type": "boolean" }, "maxitems": 10 } at beginning entries send. later on entries changed , these new values must updated. if syntax @ beginning when send full array is: [{"linegroup":"false"},{"linegroup":"true"},...,{"linegroup":"true"}] what syntax send 1 or 2 entries have changed in array? need resend whole array? you use json patch update original json object: http://jsonpatch.com/ the cool thing patch documents json documents.

libraries - Which should I use: Python-sgp4, PyEphem, python-skyfield -

the landscape of python tools seem accomplish task of propagating earth satellites/celestial bodies confusing. depending on you're trying do, pyephem or python-sgp4 may more suitable. of these should use if: i want ecef/eci coordinates of earth satellite i want general sky coordinates of celestial object near earth vs. far away objects want use two-line element sets do of these accomplish precise orbit determination? if not, go/what resources there out there precise orbit determination? i kind of know answers here. instance, pod not part of of these libraries. these computations seem involved. pod many objects available igs. main reason ask documentation purposes. i'm not familiar python-skyfield, have hunch accomplishes these other 2 do. --brandon rhodes, await expertise :)

what is the process of the running the java files that are present in testng xml using ANT -

i want know process of running java files mentioned in testng.xml using ant. do have compile java files first , run it? or testng ant task takes care of compiling , running? have gone through testng ant task code didn't quite it. can explain? <taskdef resource="testngtasks" classpath="testng.jar" /> <testng classpathref="run.cp" outputdir="${testng.report.dir}" sourcedir="${test.src.dir}" haltonfailure="true"> <xmlfileset dir="${test14.dir}" includes="testng.xml" /> </testng> according testng doc one of attributes classpath, classpathref or nested must used providing tests classpath. which means have compile test classes before running tests.

javascript - how to make text align right in labels inside row -

i trying make simple demo given in image ![enter image description here][1] i able display contend in view .but facing few issue in making page how add background image in contend .i don't have same background image have similar background image in url how make text align left in application .the end character in sigle line .how make label left align. how add separator line in grid view .actually in row separator present. here code <html ng-app="ionicapp"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>tabs example</title> <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet"> <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script> </head> <body> </body> <ion-view...

OpenGL How to use a invisible mask to hide objects behind it -

i have opengl problem solve. have object/mesh a, object/mesh b , background texture c. initially framebuffer filled background texture c. draw both & b in framebuffer. want keep object visible, , object b invisible. in beginning, in front of b. during rotation, @ angle, b in front of based on depth test result, since b invisible, b's part should filled background c. does know simple approach solve issue? is stencil test approach? set object b color, compare color of b background c, , show background c when test fail. does have sample code can read? the easiest solution to: draw c; draw b colour mask preventing writes frame buffer (but don't touch depth mask, writes still made depth buffer); draw a, subject depth test. the specific thing use glcolormask — if supply gl_false each channel via subsequent geometry won't write colour output. assuming haven't touched gldepthmask it'll still write depth output. so, you've got code...

c - C11 stdatomic and calloc -

i've got structure contains atomic field: #include <stdatomic.h> struct s { ... atomic_int a; }; this structure allocated calloc : struct s *p = calloc(1, sizeof(struct s)); is portable expect p->a initialised 0? there enough barriers in code weakly consistent initialisation fine, initial value guaranteed 0? no, not portable in general. calloc guarantees byte-wise 0 value of underlying object. types (may) have state not equivalent initialization. definitively have use atomic_init put object valid state. the reason platforms hold "lock" in addition base object because don't implement corresponding assembler instruction. portable need use atomic_var_init or atomic_init atomic objects not statically allocated. that said, don't know of existing platform need such cruft atomic_int . if platform has atomic_int_lock_free set 2 , sizeof(atomic_int)==sizeof(int) , can relatively sure strategy works. test in _static_assert...

ruby - how do I stop duplicate log lines when using log_buddy? -

i using log_buddy ruby gem. however, getting duplicates in console , in log-manager: last_response going cache: d, [2015-05-29t16:59:37.612481 #632] debug -- : last_response going cache: the code appears looks this: d "last_response going cache:" d {last_response} how stop duplicates?

php - Multi Search in Table -

how can perform multi-search in table in php? here's code: <form action="" method="get"> <input type="text" class="span4" placeholder="cari nama" name="carinama" style="margin-top:10px;" /> <input type="text" class="span4" placeholder="cari dob" name="caridob" id="datepicker" autocomplete="off"style="margin-top:10px;" /> <input type="text" class="span4" placeholder="cari role" name="carirole" style="margin-top:10px;" /> <button class="btn btn-primary" type="submit"><i class="fa fa-save fa-fw"></i> cari</button> </form> here, querynumber : </div> </div> <div class="row-fluid row-merge"> <?php $querymember = "select u.*, r.* m_user u left join ...

c - PETSC_VIEWER_DRAW_WORLD shows nothing -

i started petsc , i'm trying plot matrix using matview. code like: matcreateseqaijwitharrays(petsc_comm_world, nodes, nodes, rows, cols, values, net); //i want visualize "net" //visualization if(display >= 1){ petscprintf(petsc_comm_world, "csr structure created.\n"); matview(*net,petsc_viewer_draw_world); } when use matview way: matview(*net,petsc_viewer_stdout_world); i can see list rows. when change to matview(*net,petsc_viewer_draw_world); nothing happens. i can't see net structure, not list. i tried run examples don't work @ all. also, petsc documentation makes things worse. can me? don't want see list of rows, matrix (graphically). more context comments: x windows functioning -- able confirm gvim , xlogo , xeyes , etc. library has been rebuilt using --with-x option in configure . still nothing appears. try using "-draw_pause -1" argument petsc program, if you're ...

sql - How to get the hour difference between 2 datetimestamp on derby db? -

i have sql question on derby database: select a.name, a.starttime, a.endtime how can add above sql statement such can difference in hours between start time , end time? (i know mysql there datediff function, not sure function should use derby db) thanks. in derby there timestampdiff: for instance: select {fn timestampdiff(sql_tsi_frac_second, startdate, enddate)} diff

css selectors - Is it possible to add text to every image path on hover using CSS? -

i'm wondering, have alot of image on website behave depending on class. wondering if possible using css example. .willreactonhover.class1{ background: url('../images/image1.png');} .willreactonhover.class2{ background: url('../images/image2.png');} and then, on hover .willreactonhover:hover{ background: /*here, .class1 .image1-hover.png , .class2 .image2-hover.png */ } i don't know if it's possible had suffix -hover existing path if different... know in javascript i'd love pure css solution else i'll have create hover event every class since it's same task each class don't know if there's way it'd optimal. or maybe there css selector use achieve this? before css-3 people used background-position along image-sprite use old-horse background-position , : .willreactonhover.class1{ background: url('../images/image1.png');} .willreactonhover.class2{ background: url(...

swift - use Alamofire to show image in collectionView in ios -

i use alamofire library showing image in cell in collectionview problem when scrolling && down , collectionview showing wrong image in cell and snippet code set cell data override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell = collectionview.dequeuereusablecellwithreuseidentifier(reuseidentifier, forindexpath: indexpath) as! cardviewcell let pos = indexpath.item % 5 var paragraphstyle = nsmutableparagraphstyle() paragraphstyle.linespacing = 2.5 paragraphstyle.alignment = .right paragraphstyle.linebreakmode = .bytruncatingtail if let text = currentcollection.titles?[indexpath.item] { var attrstring = nsmutableattributedstring(string: text) attrstring.addattribute(nsparagraphstyleattributename, value: paragraphstyle, range:nsmakerange(0, attrstring.length)) cell.title.attributedtext = attrstring } else { cell.tit...

java - How can i get all Changelists of a branch since a specific Changelist? -

i use perforce java api make list of changelists since specific changelist of branch. on command line can with: p4 changes -l branchname@changelistid,#head. use api. list<ifilespec> filespecs = new arraylist<>(); filepath path = new filepath(pathtype.depot, p4branch + "/..."); filespec filespec = new filespec(path); filespec.setchangelistid(changelist.getid()); printfilespec(filespec); filespecs.add(filespec); try { changelists = server.getchangelists(100, filespecs, null, null, false, true, false, true); if(changelists.isempty()) { system.out.println("empty changelists"); } else { system.out.println("changelists has " + changelists.size() + " elements"); } } catch (exception e) { e.printstacktrace(); } with filespec.setchangelistid(changelist.getid()); can set give me changelists before changelist (which similar command: p4 changes -l branchname@change...

Load folder on specific Wordpress URL(category URL) with .htaccess -

i'm trying load content(index.html) specific folder on specific(already used url) in wordpress. here's .htaccess file(default): # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress i've tried few variations of rewrite rule: rewriterule ^/category/funny-posts/ /funny-images/ [l] so funny-images directory on server have wp installed. both of them in root folder. how can load index.html /funny-images/ when type www.site.com/category/funny-posts/ ? if index.html file not displaying (and uri want being passed wp) it's because you're putting rule @ end. try putting after rewriteengine on . oh, , don't think you'll need rewritebase . also, don't need leading slash in new rule, before category . your file should this: # begin wordpress <if...

sql - extremly disproportionate running time for query. Trying to understand RDBMS -

i working customers database (db2) our company has read access. hence don't have control on indices, schema , like. want emphasize point, because there still might indices don't know where. have optimize our query differently. anyway, i'm more interested in understanding how these things work rather in workaround (although i'm interested in too). expected dbs fast these kind of operations apparently not. or maybe running serious pitfall. the scenario: dissected our query , stripped down following incomprehensible me. let call query q1 of form select c.cid, c.bid, c.ryear, t.tyear, td.nr myschema.ctable c join myschema.dtable d on d.cid = c.cid join myschema.iptable ip on (ip.did = d.did , ip.type = 'type_s') join myschema.ttable t on t.xtime = ip.xtime join myschema.tdtable td on c.tdid = 'type_'||td.oid c.ryear = 2009 , d.rr = 'ugk' , d.stat = 'stat#1' ; this query retrieves 8000 entries , takes on minute execute. n...

python - Scraping Data From Interactive Map -

i scrape voter registration data underlying map: http://www.bostonglobe.com/metro/2012/08/28/registration-figures-show-massachusetts-voters-continue-abandon-two-major-political-parties/p0zw7snj9r07dk913p36km/igraphic.html?p1=article_graphic as hover on each town, both total , by-party figures in box below change. record name of each town , registration counts party. suggestions how helpful. i've done scraping in past not interactive , first few attempts various python packages haven't worked. (unfortunately, sources link @ bottom not useful because links secretary of state's main page , original report data no longer available) no need build app scrape this, looked @ source of page 5 min, check out: http://www.bostonglobe.com/r/boston/2011-2020/webgraphics/metro/bostonglobe.com/2012/08/voter/voter-regs.js otherwise you need have technology has javascript engine, phantomjs or firefox/chrome drivers. if want stick python, selenium webdriver way go. ...

How to test django's front-end javascripts -

i'm trying test django powered website's backbone.js front-end. i found out karma.js , jasmine frontend testing, seems "front-end" , means cannot test interactions between front-end backbone models , django rest api server. what i'm looking testing framework can test front-end javascripts in bdd style ( including interactions between front-end , back-end ). i know there few tools testing dom, such selenium or lettuce , etc. want test front-end "javascript" , not dom, , that's why tried out karma.js , jasmine @ first. is there testing framework can test front-end back-end network interactions? or there way tweak karma.js work nicely django's development server? lettuce + selenium + django's liveservertestcase best option system/integration testing in tdd enviroment. liveservertestcase supports testing fixtures handles set , tear down of working test server. karma , jasmine great low-level, unit testing (ie thin...

Get Holo Timepicker in Android L -

Image
i getting new timepicker using support library. need show holo style time picker 30 min time interval. i using following code: public void showtimepickerdialog(calendar calendar) { selectedcalendarinstance = calendar; timepickerdialog timepickerdialog = new timepickerdialog(activity, r.style.dialogtheme, this, 10, 0, false); timepickerdialog.settitle(null); timepickerdialog.show(); } but need following style of timepicker please help! thanks in advance! i go custom dialog timepicker as <timepicker android:timepickermode="spinner" ... ... ... />

vb.net - So a VB interface can't have shared functions. Is there an alternative to creating dummy objects? -

to avoid getting weeds on particular program, let me create simplified case. i have generic class should work on variety of objects. each of objects must implement interface. what want like: public interface genthing shared function thing_name() string ' doesn't work! can't shared! sub fillone(row datarow) end interface public class thing1 implements genthing public shared function thing_name() string implements genthing.thing_name return "thing number one" end function public sub fillone(row datarow) implements genthing.makeone ... bunch of work ... end sub end class public class thingutil(of t {genthing,new}) public function getlist(id integer) list(of t) dim name=t.thing_name() ' doesn't work! dim ds dataset=getdata(name,id) ' bunch of work here that's whole point of class not relevant question dim my_list = new list(of t) each row datarow in ds.tables(0).rows ...

wcf - Architecture Design for API of Cloud Service -

background: i've local application process user input 3 second (approximately) , return answer (output) user. (i don't want go details application in purpose of not complicate question , keep pure architectural question) my goal: i want make application service in cloud , expose api (for upcoming website , clients connect service without install software locally) possible solutions: deploy wcf on cloud , use application there, clients can invoke service , use application on cloud. (rpc style) use web-api insert request queue , worker role dequeue requests , post results db, client send 1 request creating request in queue, , request getting result (which web-api db). the problems: if go wcf solution (#1) cant handle great loads of requests, maybe 10-20 simultaneously. if go webapi-queue-workerrole solution (#2) client need request results multiple times can problem. if go webapi-queue-workerrole solution (#2) process isn't sync, client not result o...

wordpress - PHP session cookies to expire when browser closes -

i working in wordpress , have following in functions.php page. i have array of 3 different styles. cookie doing randomizing. if (isset($_cookie['style'])){ $style = $_cookie['style']; } else { $style = ($rand[$stylearray]); setcookie('style',$style,time(),cookiepath,cookie_domain,false); } i want set cookie only expires when browser closes. however, seems on page refresh(f5) cookie expires. is there way set cookie expires on browser close? the http://www.w3schools.com/php/func_http_setcookie.asp says optional. specifies when cookie expires. value: time()+86400*30, set cookie expire in 30 days. if parameter omitted or set 0, cookie expire @ end of session (when browser closes). default 0 so setcookie('style',$style, 0 , ...); or setcookie('style',$style, '', ...); must work.

ruby on rails - Parameter passing and assert_difference -

i new both ruby , rails. don't understand why following code (which uses rails' [activesupport::testing.assert_difference] 1 method) doesn't require comma after parameter 1 . code comes chapter 7 of rails tutorial. assert_difference 'user.count', 1 post_via_redirect users_path, ... end the signature assert_difference is: assert_difference(expression, difference = 1, message = nil, &block) thus expect comma required between difference parameter , block parameter not case. why comma not required? blocks aren't parameters - shows in method signature method captures block passed in proc, implementation detail leaked outside world. example if define method this def foo(*args) end then blocks passed method don't end in args . however if passing proc (or responds to_proc ), using & argument prefix wish argument used method's block need comma. my_proc = -> {post_via_redirect users_path} assert_difference user.cou...

c# - How to get Moq to verify method that has an out parameter -

i have interface definition method has out parameter defined public interface irestcommunicationservice { tresult performpost<tresult, tdata>(string url, tdata datatosend, out standarderrorresult errors); } i have following class using above interface public tripcreatedispatchservice(irestcommunicationauthservice restcommunicationservice, isettings settings) { _restcommunicationservice = restcommunicationservice; _settings = settings; } public flightalert createtrip(string consumernumber, postalertmodel tripmodel, out standarderrorresult apierrors) { url = .. code ommited var result = _restcommunicationservice.performpost<flightalert, postalertmodel>(url), tripmodel, out apierrors); return result; } in unit tests trying verify performpost method of restcommunication object called. but no matter do, cannot moq verify method called public void dispatchservice_performpost() { v...

STREAM video from ANDROID device to OPENCV real time -

i'm working google glass (it considered normal android device) , opencv lib (c++). need transfer (real-time) video source android camera visual studio , process on pc. not processing video directly in glass because computationally expensive. tried stream using rtsp, http.. protocols quality of frames bad , there inconvenient latency. hence, wondering if of know how stream video via usb , on visual studio. read using adb not seem have real-time function. otherwise i'am ears suggestion. thank in advance!! matt you can use adb forward foward tcp port on usb. that should allow open socket between android device , host pc through usb data transfer, should give fast enough speeds send frames pc in real-time , analyse them in opencv. can send frames bytes on socket.

ios - Swift - NSHTTPCookie is nil -

i trying write couple cookies in swift when display webview, able read cookies , react appropriately. found many examples of how create cookie , read apple docs can not seem valid nshttpcookie object. it's nil. here's code: let basehost = "domain.com" let oneyearinseconds = nstimeinterval(60 * 60 * 24 * 365) func setcookie(key: string, value: anyobject) { var cookieprops = [ nshttpcookieoriginurl: basehost, nshttpcookiepath: "/", nshttpcookiename: key, nshttpcookievalue: value, nshttpcookiesecure: "true", nshttpcookieexpires: nsdate(timeintervalsincenow: oneyearinseconds) ] var cookie = nshttpcookie(properties: cookieprops) // line fails due nil cookie nshttpcookiestorage.sharedhttpcookiestorage().setcookie(cookie!) } my cookie variable nil . i've tried many combinations of properties including having both nshttpcookieoriginurl , nshttpcookiedomain , , without nsh...

javascript - Using @import in content script's associated CSS -

i'm building chrome extension includes content script linked css file. that's manifest file: { "manifest_version": 2, "name": "cool name", "version": "1.0", "permissions": [ "http://*/*", "https://*/*", ], "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "js": [ "jquery.js", "contentscript.js" ], "css": [ "styles.css" ] } ], "web_accessible_resources": [ "styles.css" ] } these contents of styles.css : @import url(http://fonts.googleapis.com/css?family=pacifico); .testclass { font-family: pacifico; } as can see, i'm trying import google font css file. however, font doesn't seem loaded, because when try use font, applying testclass text ele...

rust - pattern matching borrowed content issue -

so have piece of code reads input.csv , inserts column in , writes output.csv extern crate csv; use std::path::path; struct user { reference: string, email: string, firstname: string, lastname: string } fn main() { let mut rdr = csv::reader::from_file("/tmp/input.csv").unwrap().has_headers(false); let mut wtr = csv::writer::from_file(path::new("/tmp/output.csv")).unwrap(); let users = get_users(); record in rdr.decode() { let rec: option<vec<string>> = match record { ok(rec) => some(rec), err(e) => none }; match rec { some(mut r) => { let usr = users.iter().find(|&ur| ur.reference == r[27].to_string()); match usr { some(u) => r.insert(1, u.email), none => r.insert(1, "unknown".to_string()) } wtr.write(r.iter()); ...

python - Using QThread for a throbber -

i add throbber gui when actions launched. here script : class starttask(qtcore.qthread): taskstarted = pyqtsignal() def run(self): self.taskstarted.emit() class stoptask(qtcore.qthread): taskstopped = pyqtsignal() def run(self): self.taskstopped.emit() class projet(object): def __init__(self): self.movie = '' # throbber self.starttask = starttask() self.starttask.taskstarted.connect(self.startthrobber) self.stoptask = stoptask() self.stoptask.taskstopped.connect(self.stopthrobber) def startthrobber(self): # set movie screen on label self.movie_screen = qlabel() # expand , center label main_layout = qvboxlayout() main_layout.addwidget(self.movie_screen) ui.throbbertab2.setlayout(main_layout) # use animated gif file have in working folder bytef = qbytearray() movie = qmovie("d:\various\images\loader.gif", byt...

android - Can I implement the reverse geocoding function within my ActivityMaps.java file? -

im developing app in android studio 1.1.0 , have implemented google maps api can retrieve users current location convert address. can use following code in mapsactivity.java file? function getreversegeocodingdata(lat, lng) { var latlng = new google.maps.latlng(lat, lng); // making geocode request var geocoder = new google.maps.geocoder(); geocoder.geocode({ 'latlng': latlng }, function (results, status) { if (status !== google.maps.geocoderstatus.ok) { alert(status); } // checking see if geoeode status ok before proceeding if (status == google.maps.geocoderstatus.ok) { console.log(results); var address = (results[0].formatted_address); } }); } any appreciated. still relatively new android studio you can using android.location.geocoder . // current locality based on lat lng geocoder geocoder; list<address> addresses; geocoder = new geocoder(this, locale.getdefault()); ...

java - On Item Click in gridview my next activity is not showing -

i building app of universal image loader library. main activity loads images urls , shows in gridview. want show full image in separate activity. when clicks on image open in new activity, application crashed. i unable understand sample code given uil, lengthy. so, wanted make grid view activity. here code: imagelistadapter.java public class imagelistadapter extends baseadapter { public string[] urls = { "https://lh6.googleusercontent.com/-55osaww3x0q/urquutcfr5i/aaaaaaaaabs/rwlj1rukryi/s1024/a%252520photographer.jpg", "https://lh4.googleusercontent.com/--dq8nirp7w4/urquvgmxvgi/aaaaaaaaabs/-gnulqfnnba/s1024/a%252520song%252520of%252520ice%252520and%252520fire.jpg", "https://lh5.googleusercontent.com/-7qzedtrkfkc/urquwzt1goi/aaaaaaaaabs/hqwgteynxsg/s1024/another%252520rockaway%252520sunset.jpg", "https://lh3.googleusercontent.com/--l0km39l5j8/urquxhgcdni/aaaaaaaaabs/3zrsjnrsomq/s1024/an...

Grails Basic Authentication credentials passed in URL -

i'm trying access url fetch json file grails application, not find way pass authentication credentials. i'm trying code pass authentication string url = 'http://urlthatiwanttogoto.com' string id = 'my_id' string pw = 'my_pw' string website = 'http://my_id:my_pw@urlthatiwanttogoto.com' string jsonfile = new jsonslurper().parsetext(new url(website).text) but i'm still getting 401 errors.

linux - Search Multiple directories and return one result -

i'm trying bring piece of code had running on aix box on linux , can't work. [ -f $folderpath/*/filename.txt ] && echo 1 || echo 0 the above searchs folderpath , * subdirectories looking filename.txt. if found (more once), returns 1, otherwise returns 0. in linux, many arguments error, thought changing [[ ]] fix this, doesn't seem handle wildcard * in that. anyone ideas? thanks you try following command , query status code $? : find $folderpath -name 'filename.txt' | grep -e '*' this returns 1 when there no files listed find command , 0 when there are. optionally, if you're interested in hitting specific level avoid deep searches down directory tree can use -maxdepth n option.

pthreads - PHP thread - run method not being called -

for reason run method not being called? ideas i'm going wrong? <?php class workerthread extends thread { private $i = 0; public function __construct( $i ) { $this->i = $i; } public function run() { $a = 0; while( $a < 100 ) { file_put_contents( "test" . $this->i . ".txt", $a, file_append ); sleep( 5 ); } } } $workers = array(); ( $i = 0; $i < 3; $i++ ) { $workers[ $i ] = new workerthread( $i ); $workers[ $i ]->start(); } ?> in while loop, $a never changes , causes infinite loop (it's equal zero).

How can i change javascript script into a jquery functional code -

hey guys new jquery,how can change javascript code jquery functional code call whenever want @ object like: $("#profile_img").uploader(); apparently code works fine, problem have have populate code every time need upload file in different file input upload. var input = document.getelementbyid("choosen_feeds_image"), formdata = false; if (window.formdata) { formdata = new formdata(); document.getelementbyid("feeds_upload_btn").style.display = "none"; } if (input.addeventlistener) { input.addeventlistener("change", function (evt) { var = 0, len = this.files.length, img, reader, file; document.getelementbyid("response").innerhtml = "" (; < len; i++) { file = this.files[i]; if (!!file.type.match(/image.*/)) { if (window.filereader) { reader = new filereader(); reader.onloadend = ...

android - Use Toolbar.OnClickListener instead of ActionBar.TabListener? -

Image
i new android , used android template (tabbed activity - viewpager , fragments) , noticed actionbar , actionbar.tablistener deprecated. replaced actionbar appcompatactivity recommended, wondering should use instead of tablistener. can use onclicklistener nested class in toolbar class ? node: app works fine deprecated interface, want use interface not. public class mainactivity extends appcompatactivity implements actionbar.tablistener { this screenshot of app i recommend use material design tabs. use viewpager , same. advantage is, material tabs actual tabs. when use actionbar.tablistener (deprecated), not tabs. actionbar tabs, which.. if rotate screen, place automatically on actionbar on top. read documentation here adding navigation tabs so implement material design, new , best solution tabs. started, guess best tutorial material design tabs

javascript - alert(new Boolean(false)) vs console.log(new Boolean(false)) -

i wonder why alert(new boolean(false)) prints false instead of printing object new boolean should return object. works should work if use console.log(new boolean(false)) alert() displays .tostring() value of argument passed it. the tostring() value of boolean object either true or false .

javascript - Modify state data for non-child react component -

i have 2 , independent react classes var user = react.createclass({ .... updategamescore: function(){ this.game1.score = .... } render: function(){ return ( <div>{this.state.totalscore}</div>); }); var game = react.createclass({ .... updateuserscore:function(){ how access/modify parent here??? }, render: function(){ return ( <div>{this.state.score}</div>); }); i need able update user totalscore when game score changes , vice versa based on formula (irrelevant here). components such game nested in user child component cannot vice versa. change in user score can update game score passing down variable using this.state(..) , when game score changes, way can use update correct parent user score (there can more 1 users @ time) you can pass handler function user game via props: var user = react.createclass({ ... handlescorechange: function(newscore) { this.setstate({totalscore: newscore}); } rende...

android - how to display widget on home screen? -

i working on launcher.i list of widgets of installed app.when click on widget want on home screen.i searched solution.but didn't idea.what have do?please me. it not possible app place widget in home screen. home screen can add app widgets home screen. similar links link1 , link2 , link3 but can offer user pick widget widgetpicker. intent pickintent = new intent(appwidgetmanager.action_appwidget_pick); pickintent.putextra(appwidgetmanager.extra_appwidget_id, appwidgetid); startactivityforresult(pickintent, key_code);

objective c - Setting the HTTP-Proxy/network settings for a specific Wifi network programatically on iOS -

i need change settings specific wifi network set http-proxy (or alternatively static network settings) programatically on ios automation tasks. possible on ios? i'm totally unaware of platform @ all, i'm sorry if trivial answer. if matter: can use jailbroken device prefer solution doesn't rely on that. i've read little bit ui automation, maybe it's possible through if it's not possible via program?

cakephp - How to pass 2 variables in viewVars -

$message[0] = $unique_password[0]['users']['firstname']; $message[1]='please click on link reset password: http://test.com/reset_password?password='.$unique_password; $email = new cakeemail(); $email->config('smtp'); ***$email->viewvars($message[0],$message[1]);*** $email->template('forgetpassword') ->emailformat('html') ->to($email) ->from('app@domain.com') ->subject('password: urbanbeauty network') ->send(); i need send 2 variables on view $message[0] & $message[1] in viewvars. how achieve this? please help. you need this, $this->set('message', $message); , in view have $message[0] , [1]

matlab - vectorization for array products -

how can vectorize loop ? let b = real array of size (2,3) m = real array of size (7,2) y = real array of size (n,3) b , m constant , n "big" (in problem, n > 80000). i want optimize (vectorize) loop : for k=1:max(size(y)) r=b*y(k,:)'; p(k)=r'*m; end help appreciated first p(k)=r'*m wrong (b*y(k,:)' (2x1) , m (7x2)) so think mean p(k)=r'*m'; then b (2x3) y (nx3) r= b*y' (2xn) r' (nx2) m' (2x7) p=r'*m' (nx7) so don't need use loop , can write: p=(b*y')' m' or p=(m (b*y'))'

angularjs - Routing in ionic with nested tabs does not work -

hello new both ionic , angular js. started framework yesterday stuck in process below. trying create nested tab views inside view. it's not working. listing part menu view tabs: <ion-item class="item-icon-left" menu-close href="#/app/browse"> <i class="icon ion-ios-stopwatch"></i> browse </ion-item> <ion-item class="item-icon-left" menu-close href="#/app/tab"> <i class="icon ion-ios-calendar"></i> tabs </ion-item> this tabs view: <ion-view view-title="tabs"> <ion-content> <ion-tabs class="tabs-icon-top tabs-color-active-positive"> <ion-tab title="status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/app/tab/dash"> <ion-nav-view name="tab-dash"></ion-nav-view> ...

Does HERE Map tile REST API support CORS -

i'm going use satellite tiles texture terrain mesh. when create texture out of security error. does here map tiles server support cors? or have workaround (proxy / php)? in general tiles support cors , should able check response header 'access-control-allow-origin:*' verify that. can share simple example facing security error ? , in browser ?

javascript - how to copy static uploaded input data to another upload input data in the same html page for firefox -

i trying upload file , copy uploaded data upload input button <input type="file" id="myfile"> <input type="file" id="myfile1"> <script> var control = document.getelementbyid("myfile"); control.addeventlistener("change", function(event) { var = 0, files = control.files; console.log("filename: " + files[i].name); console.log("type: " + files[i].type); console.log("size: " + files[i].size + " bytes"); var control1 = document.getelementbyid("myfile1"); var = 0; control1.files = control.files; alert(document.getelementbyid("myfile1").files[0].name); }, false); </script> the above scenario seems work in chrome it's not working in firefox , ie

c++ UDP socket programming in ubuntu -

i'm trying learn udp socket programming in c++ can't find useful tutorial , useful example code . can me find some? here, should follow either if you're on windows or linux: http://www.techpowerup.com/forums/threads/c-c-sockets-faq-and-how-to-win-linux.56901/

mainframe - Is it extraordinary that a BMS application does the same thing slower than a CICS Web Support application? -

on zos 2.1, cics-ts 5.1 installed. we have bms-cics-vsam application suite. has bms front back-end cics applications modifying vsam records. uses exec cics link back-end applications have no user interface of own. we thought increasing usability of that. so, front bms application scrapped , new cics web support (not cics web services!) written - basic, barebone html pages. when user formsubmit, web interface exact same exec cics link exact same end-applications (they weren't modified @ all). the performance increased , makes no sense. hoping more experienced cics web interface comment , tell me if it's normal web pages quicker 3270 bms?

jquery - executeScript not populating global variable - Chrome Extension -

i building chrome extension , have array variable array_out empty. need array populated values of array comes within executescript on callback function. but, reason global array array_out isn't being populated, console.log shows, because chrome function running after jquery? any help? the code have follows: $(document).ready(function(){ var array_out = []; chrome.tabs.query({currentwindow: true, active: true}, function(tabs) { chrome.tabs.executescript(tabs[0].id, { code: " \ var array_in = ['one', 'two', 'three']; \ " }, function(result){ array_out = result[0]; console.log('in: ' + array_out.length); }); }); console.log('out: ' + array_out.length); }); you using 2 functions execute asynchronously. provide callback function both chrome.tabs.query , chrome.tabs.executescript attempt access variable set ...

php - Convert Subquery SQL to Laravel possible? -

is possible change sql let work on laravel? select name, event,m.season_id, tm.played_pugs, active, m.created_at, datediff(now(),m.created_at) matchs m left outer join seasons on seasons.id = m.season_id join ( select season_id, max(matchs.created_at) maxdate, count(season_id) played_pugs matchs group season_id) tm on m.season_id = tm.season_id , m.created_at = tm.maxdate order played_pugs descc> this have far: $seasons = db::table('matchs') ->select('name', 'event', 'season_id', 'played_pugs', 'active', db::raw('datediff(now(),created_at) days')) ->join('seasons', 'seasons.id', '=', 'matchs.season_id', 'left outer') ->join(db::raw('select season_id, max(matchs.created_at) maxdate, count(season_id) played_pugs matchs group season_id)'), '') ->orderby('played_pugs','desc') ->ge...

Algorithm equalivence from Matlab to Python -

Image
i've plotted 3-d mesh in matlab below little m-file : [x,n] = meshgrid(0:0.1:20, 1:1:100); mu = 0; sigma = sqrt(2)./n; f = normcdf(x,mu,sigma); mesh(x,n,f); i going acquire same result utilization of python , corresponding modules, below code snippet: import numpy np scipy.integrate import quad import matplotlib.pyplot plt sigma = 1 def integrand(x, n): return (n/(2*sigma*np.sqrt(np.pi)))*np.exp(-(n**2*x**2)/(4*sigma**2)) tt = np.linspace(0, 20, 2000) nn = np.linspace(1, 100, 100) t = np.zeros([len(tt), len(nn)]) i,t in enumerate(tt): j,n in enumerate(nn): t[i, j], _ = quad(integrand, -np.inf, t, args=(n,)) x, y = np.mgrid[0:20:0.01, 1:101:1] plt.pcolormesh(x, y, t) plt.show() but output of python is considerably different matlab one, , matter of fact unacceptable. afraid of wrong utilization of functions linespace , enumerate or mgrid ... does have idea about?!... ps. unfortunately, couldn't insert output plots within thread......

javascript - Log out restriction in php -

i making website using javascript , php. when user logout website , if clicks button of browser goes previous state in user logged in. 1. how can restrict this? 2. can done sessions, or else? use sessions login.php: ... $_session["foo"] = $foo; ... logout.php: ... unset($_session["foo"]); ... in login.php set session variable named foo (so user logged on). when logs out, destroy/unset session variable named foo , in each logged in page may want if statement checking if session variable set(logged in) else (not logged in) can redirect user ever want to.

python - Unittest tearDown() method depends on finished test -

i write selenium tests, , have problem. before each test upload different files every test, , after test done, want remove these files application if test failed. there 2 methods setup , teardown . called before , after every test, how can define test finished in teardown method? important me, because after each test want remove different files application, depending on finished test. i want like: def teardown(self): if test1_is_finished(): remove_test1_files if test2_is_finished(): remove_test2_files # , on i new python , selenium tests, , maybe better approach exists job after after test finished, if failed. in setup method (to run before every test), create list, to_be_removed : def setup(self): self.to_be_removed = [] in each unit test, append filenames to_be_removed : def test1(self): ... self.to_be_removed.append(filename) then, in teardown , remove files listed in to_be_removed : def teardown(self): filena...