Posts

Showing posts from February, 2012

python - How to write to a csv file on the local file system using PySpark -

i have code writing csv file on local filesystem error - ioerror: [errno 2] no such file or directory: 'file:///folder1/folder2/output.csv' columns = [0,1,2,3,4,5,6,7,8,9] data1 = rdd1.map(lambda row: [row[i].encode("utf-8") in columns]) data1_tuple = data1.map(tuple) open("file:///folder1/folder2/output.csv", "w") fw: writer = csv.writer(fw, delimiter = ';') (r1, r2) in izip(data1_tuple.tolocaliterator(), labelsandpredictions.tolocaliterator()): writer.writerow(r1 + r2[1:2]) on local filesystem following directory exists - /folder1/folder2/ . why throwing error , how can write csv file on local filesytem @ specific directory? path argument open either string or bytes object giving pathname (absolute or relative current working directory) of file opened or integer file descriptor of file wrapped not uri. means code should follows: with open("/folder1/folder2/output.csv", "w")

ios - Splash Screen(Welcome) Before Tab View -

Image
so i'm trying program ios app in swift, there splash screen before tab bar screen. i've looked @ both: http://sweettutos.com/2014/01/08/present-a-login-screen-before-the-tab-bar-controller-in-a-uitabbarcontroller-based-app/ and loading welcome screen(splash screen) before tabbarcontroller but both of them require nib file , did ui in storyboard. here's main question: code on website has this: controllername(nibname: "nibname", bundle: nil); is there way same thing without nib file , use storyboard? thanks in advance! assuming have tabbarcontroller in storyboard, add view controller next it. then click on new view, , in attributes inspector, check off "is initial view controller". that makes new view first thing comes when app opened. go tabbarcontroller, have button on first view has segue(control drag) tabbarcontroller .

java - paginated calls on a service method without changing signature of original method -

i have use case need add pagination inputs (viz. page number , page size) existing service calls (that returns list of results) without changing existing signature (because break existing clients). 1 way of achieving set inputs in threadlocal , have implementation read threadlocal , pagination logic. code point of view, like: try { paginationkit.setpaginationinput(pagesize, pagenumber); // set threadlocal list<specialobject> results = specialservice.getspecialobjs(); //results count equal pagesize value } { paginationkit.clearpaginationinput(); // clear threadlocal } from client's point of view, not @ elegant , wanted wrap functionality better syntactic sugar. there 2 approaches had in mind , wanted know if generic enough use case has been solved pattern elsewhere. there many such services , trying put decorator each of services not desirable. approach 1: mockito style of mockito.when(methodcall).thenreturn(result) kind of sugar. code may like: speci

php - Javascript eval() doesn't work as expected -

i'm fetching data php function in json format. var xhreq = new xmlhttprequest(); xhreq.open("get", "http://myserver/getjson", false); xhreq.send(null); var serverresponse = xhreq; var jsondata=eval("("+serverresponse.responsetext+")") //retrieve result javascript object images=""; for(var i=0; i<jsondata.length;i++) { images+=" ['"+jsondata[i].title+"','"+imagesroot+"121a.png"+"']"; if(i<jsondata.length-1) images+=","; } im getting data in following format. ['title 1','http://site.com/images/121a.png'], ['title 2','http://site.com/images/121a.png'], ['title 3','http://site.com/images/121a.png'], ['title 4','http://site.com/images/121a.png'] finally when im assigning data array using eval() var tinymceimagelist = new array(eval(images)); it show last eleme

jquery - center bottom element to parent div -

hi have little problem. want add few div centered element on bottom. tried this: position:absolute; min-width:73px; min-height:52px; margin: 0 auto; left: 0; right: 0; bottom:0px; but doesn't work. code set each div on same position (bottom of vh). i'm using bootstrap, maybe info solve problem? full code: <div class="row container-box> <div class="col-md-10 col-md-offset-1" > //some stuff </div> <a href="#second"><span id="myid" class="glyphicon glyphicon-chevron-down "></span></a> </div> bootstrap has class .center-block add float:none; class. on css make sure have: .center-block{ float:none display: block; margin-left: auto; margin-right: auto; } html should <div class="container"> <div class="row"> <div class="col-md-10 center-block"> //some stuff </div&

xcode - How can I load a spritekit file different than GameScene.swift in my GameViewController.swift? -

in gameviewcontroller.swift, find line if let scene = gamescene(filenamed:"gamescene") { and thought if wanted load other gamescene.swift, change "gamescene" "landingpage" , work dandy. however, figured out, "gamescene" here refers gamescene.sks , not swift file. i'm looking make game number of levels, each written in own swift file. go to/ how move from, say, level1.swift level2.swift? if in 1 scene example level selection scene, lets levelselectionscene.swift , can go scene via skview 's -presentscene:transition: method. class levelselectionscene: skscene { override func didmovetoview(view: skview) { /* ... */} func selectlevel(level: int) { let fadetransition = sktransition.fadewithduration(0.3) if let selectedlevel = createlevelscenewithlevel(level) { self.view?.presentscene(selectedlevel, transition: fadetransition) } } // not idea if progressively adding

java - How to use upn instead of DN for openLdap Authentication -

i trying authenticate against openldap server java . i tried setting ldapcontext security_principal dn , works. hashtable<object, object> env = new hashtable<object, object>(); env.put(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url, ldaphost); env.put(context.security_authentication, "simple"); env.put(context.security_principal, "cn=admin,ou=people,dc=maxcrc,dc=com"); env.put(context.security_credentials, password); env.put("java.naming.ldap.attributes.binary","objectsid"); if (sslauth) { system.setproperty("javax.net.ssl.truststore", sslkeystore); env.put(dircontext.security_protocol, "ssl"); // system.setproperty("javax.net.debug","ssl"); } ldapcontext ctx = new initialldapcontext(env, null); return ctx; } what trying authenticate using userp

c - error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token & error: expected ‘)’ before ‘va’ -

i compiling below c , .h codes in gcc terminal (centos linux) atm project received below errors. please new programming. validate_acc.h #ifndef _validate_acc_ #define _validate_acc_ struct validate_acc { int user_acc_try, = 0; int user_has_not_entered_right_acc = 1; int retries = 3; }; typedef struct validate_acc validate_acc; #endif =============================================== validate_acc.c #include<stdio.h> #include "validate_acc.h" extern int account_number; void (validate_acc va) { va.user_acc_try, va.i = 0; va.user_has_not_entered_right_acc = 1; va.retries = 3; while(va.retries > 0 && va.user_has_not_entered_right_acc == 1){ printf("\nplease enter account number: "); scanf("%d", &va.user_acc_try); if(va.user_acc_try != account_number){ printf("you entered wrong account number\n");

python - A client error (UnauthorizedOperation) occurred when calling the StartInstances operation -

Image
i add new instnace id instance i-b2117a3c. , run commands below. aws ec2 start-instances --instance-ids i-b2117a3c aws ec2 start-instances --instance-ids i-1721b699 but result picture below: a client error (unauthorizedoperation) occurred when calling startinstances operation: not authorized perform operation. encoded authorization failure message: gjgqdcdgg4iyettpm2itv1sshjbnkbssuu7re1vk6wcdh-5k1rhmsf09ali8onb5tyvkz4qjq-bt_-sxmxc5vumkmamxhy6dxyaxxksrkamyohrrboat8hjnrudyzxpwevtaukktdhg-k4uvdfdftbjrc9pna-9tg9ei5jua_-uumfmcphk3f72g94irjawvw4vjywx6w-u-_wwukjhunl8evwvq_3vyxwbdr4qhezcpvasfbobtglxhecoqgvgz1unw-b9b4nbldgd_rp-quttamqjfawowzr5deyxbhanv__adjk1r_r5zibrsoe-mzzyjjlshkm5nejgl1srgroltuixy1fyl10feo3fd-wregpp_gffeuqbutazmb4yvwx7xo6kkvreqmlnjo_7p63bl8b1_msneovorlmer7e76qj0ubwch7iija4e6dcqwzwz1lucmzhgqpiw_6s2v64_tvcrvf1u4ptwluavxd4npeujfdwfilqrhrh1sp1ljrrgb8hd4e8u3hpgvehxnivj2r60vso0wjziriuokzvtofqp1o-ne4_mdburzjxhdb6lwpdpd63m6mfd5ler8azbfwtoaxx2 may have add policy i-b

c++ - identifying the architecture of an application -

is there way figure out architecture application implementing? i'm trying figure out whether either win32, wpf or windows form being used 3rd party application. thanks help you @ exes , dlls of application, e.g. using ilspy. wpf , winforms far know limited .net framework. if not .net exe, , ilspy not parse it, win32. if .net exe, @ references. if wpf specific dlls referenced, wpf. if winforms specific dlls, winforms. if both, need trace program starting main method find evidence, api used. but either way, no strong evidence. both apis mixed, , there windows or elements of each used. since winforms wrapper of native win32 api, whenever use winforms use win32 api. so depends on need know.

javascript - AJAX Async Front end PHP REST back end -

planning create meta flight search website http://www.momondo.com.au/ after doing search, ajax async different providers , display results on listing page. question have is, best way achieve in terms of technology use? this have in mind: php rest server end returns json feed each provider, ie: www.abc.com/provider/1 (return json feed of flights) www.abc.com/provider/2 (return json feed of flights) www.abc.com/provider/3 (return json feed of flights) front end using angularjs ajax feed , populate template data feed , display results. that solution puzzle, guys have other ideas/smarter , better way achieve similar outcome? thanks

javascript - Event binding on dynamically created elements? -

i have bit of code looping through select boxes on page , binding .hover event them bit of twiddling width on mouse on/off . this happens on page ready , works fine. the problem have select boxes add via ajax or dom after initial loop won't have event bound. i have found plugin ( jquery live query plugin ), before add 5k pages plugin, want see if knows way this, either jquery directly or option. as of jquery 1.7 should use jquery.fn.on : $(staticancestors).on(eventname, dynamicchild, function() {}); prior this , recommended approach use live() : $(selector).live( eventname, function(){} ); however, live() deprecated in 1.7 in favour of on() , , removed in 1.9. live() signature: $(selector).live( eventname, function(){} ); ... can replaced following on() signature: $(document).on( eventname, selector, function(){} ); for example, if page dynamically creating elements class name dosomething bind event parent exists, document . $(document

php - Problems with htaccess directories -

so, have .htaccess code (that don't know if it's best way write it): options -indexes rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)$ index.php?p=$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)$ index.php?p=$1&$2= [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/([^/]+)$ index.php?p=$1&$2=$3 [l] and @ index.php have code load content: <div id="page-wrapper"> <? $p = ($_get['p'] ? $_get['p'] : 'home'); include_once('lib/'.$p.'.php') ?> </div> when access www.web.com/home , example, works fine loading files; when access www.web.com/articles/read/asd , other files, instead of loading www.web.com/lib/pixel.png , load www.web.com/articles/lib/pixel.png . what best way fix this? so,

php - Unable to udpate composer, getting Deprecation Notice -

Image
recently wanted add new package (laravel-dompdf) in laravel using composer. throwing deprecated notice. used composer yii2 , working. have little knowledge composer, composer experts please me. here screen short: just delete folder 'vendor' , file 'composer.lock'. 'composer global update' it works.

python - no module named numpy python2.7 -

i'm using python 2.7 on linux centos 6.5. after using yum install numpy , unable import module. from numpy import * the above code produces following error: no module named numpy why happen? cent os have default version of python 2.6.6 , might have configured python 2.7 may @ /usr/local/lib. yum install install package in site-package directory of 2.6 please check /usr/lib/python2.6/site-packages, if numpy package folder present have either install numpy python 2.7 using tarball , run setup.py. the other hack copy numpy directory 2.6 version's site-packages 2.7 version's site-package.

ecmascript 6 - EsLint from Visual Studio - Unable to use static props on javascript files -

Image
node modules: eslint 1.10.3 babel-eslint 4.1.6 eslint-plugin-react 3.15.0 sample file being linted: class notepadcomponent extends react.component { static displayname = 'notepadcomponent' static defaultprops = { activetab: 'type' } } under command line can lint , transpile using babel without issues. problem trying lint visual studio. i'm using web analyzer plugin internally uses eslint. this visual studio module defines .eslintrc file under c:\users\my-username , i've gone ahead , updated file, , main folder node_modules using configuration: "parser": "babel-eslint", "ecmafeatures": { "jsx": true, "classes": true }, "plugins": [ "react" ], "env": { "browser": true, "node": true, "es6": true, "jquery": true }, but still "jsx

What is the time complexity of Java hashCode method for the String class? -

is java's hashcode method string class computed in constant time or linear time? algorithm used? the documentation tells function: s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] it's computed once using linear-time pass, , cached it's o(1) retrieve in future.

android - updating multiple text file at once -

i'm creating app using flash cc. need create couple of text files save data. can create , save data text file can update 1 file @ time. i've used following code: for(var i:int = 1; <= 5; i++) { var file:file; file = file.documentsdirectory.resolvepath("myapp/" + this["folder" + i] + "/playinfo.txt"); var stream:filestream = new filestream(); stream.open(file, filemode.write); stream.writeutfbytes("something"); stream.close(); } the above code seems edit last file. doing wrong ? appreciated. i'm thinking of using timer instead of for-loop update single text file @ time.which approach better ? or there better solution achieve ? i'm not sure object this in context of ( this["folder" + i] ), removing this reference , using folder + i result in: myapp ├── folder1 │   └── playinfo.txt ├── folder2 │   └── playinfo.txt ├── folder3 │   └── playinfo.

How to get Facebook group created date using Graph API -

as can other details of group members, feeds etc, being admin, want created date of group using graph api. please me... thanks. there no straight option, there 2 workarounds achieve (it's not 100% perfect): you can date when group last updated: group , using updated_time field second option, can create doc, group established, , when have created doc, can access created_time field, on group docs: group-doc hope, helps.

html - HTML5 CSS Horizontally Scrolling multiple dynamic number of columns -

i having problem getting div scroll horizontally. div has dynamic number of columns can go on 100% width of page. currently, have total width set fixed px width (1500px) horizontal scrolling. however, number of columns dynamic, div should grow fit new columns in, , not hide new columns below div. here fiddle of page stripped down: https://jsfiddle.net/razzledazzle/jpj2cuo7/5/ can see last input in column visible 'last 1 visible'. next column input 'new kanban list not visible'. how can change div#board-container width 100% instead of 1500px , still scroll horizontally? it's similar layout trello or meistertask. div#main-kanban { top: 49px; position: absolute; bottom: 0; right: 0; left: 0; bottom: 52px; } div#content-kanban { position: absolute; left: 0; right: 0px; overflow: hidden; height: 100%; overflow-x: auto; background: #e3e3e3; } div#board-container { width: 1500px; top: 49px; position: absolute; height: 100%;

symfony - Authentication access control ROLES -

using symfony2.1 und fosfacebookbundle: if user typing www.example.com, e.g. user closed browser, want redirect www.example.com/secured if still authenticated. i can not in indexaction if user authenticated. my security.yml: security: encoders: symfony\component\security\core\user\user: plaintext role_hierarchy: role_admin: role_user role_super_admin: [role_user, role_admin, role_allowed_to_switch] providers: in_memory: memory: users: user: { password: userpass, roles: [ 'role_user' ] } admin: { password: adminpass, roles: [ 'role_admin' ] } my_fos_facebook_provider: id: my.facebook.user //how can add here role_user? firewalls: //standard thing fosfacebookbundle access_control: - { path: ^/, roles: [is_authenticated_anonymously] } my indexaction: if( $this->container->get('security.context') ->isgranted('is_

c# - How to use intent in fragment? (Xamarin & MVVMCROSS) -

i try call activity of loginview class fragment, facng error. code intent intent = new intent(getactivity (), loginview); startactivity(intent); the error on getactivity , on loginview please suggest use works. use this intent intent = new intent(activity, typeof(loginactivity)); startactivity(intent);

c# - Get value of a hidden column -

i have datagrid columns id,name , hyperlinkbutton on each row. id column hidden property visibility="collapsed" . on hyperlinkbutton's click event accessing columns value unable access column when hidden i.e returns null. accessible when make visible . there solution problem? xaml datagrid: <sdk:datagrid autogeneratecolumns="false" horizontalalignment="left" height="163" verticalalignment="top" name="productgrid"> <sdk:datagrid.columns> <sdk:datagridtextcolumn x:name="id" binding="{binding path=productid, mode=oneway}" header="id" isreadonly="true" width="50" visibility="collapsed" /> <sdk:datagridt

php - Detect if value in XML is present -

this question has answer here: searching xml items php xpath 1 answer trying count if name present in xml file , how many times, can help? i'm on version 35 internet code i've tried counts tags instead of content between tags. <?php $xml = <<< xml <book> <contact> <name>an smith</name> </contact> <contact> <name>alex pepper</name> </contact> <contact> <name>tom james</name> </contact> ; </book> xml; $dom = new domdocument; $dom->loadxml($xml); // detect, count if variable nametofind present $nametofind="alex pepper"; // missing code echo "$nametofind x times present in xml "; done attemps comments , working code needed: $xml=simplexml_load_file('book.xml'); $nodes= $xml->xpath("//

c++ - Error while loading shared libraries: libboost_iostreams.so.1.59.0: cannot open shared object file: No such file or directory -

i running c++ executable on ubuntu. executable links boost libraries. this output when attempt run binary: error while loading shared libraries: libboost_iostreams.so.1.59.0: cannot open shared object file: no such file or directory what should future coarse of action should take remove error. let's assume library being exist not in standard paths , you're getting error while running binary. in case try set ld_library_path environment variable point directory library located. loader search library in given path. export ld_library_path=/path/to/my/library ./run_my_binary

android - Cannot resolve locationclient -

android location client cannot resolve public class mainactivity extends fragmentactivity implements connectioncallbacks, onconnectionfailedlistener, locationlistener { private locationclient locationclient; private locationrequest locationrequest; private googlemap googlemap; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); locationclient = new locationclient(this, this, this); locationrequest = locationrequest.create() .setinterval(5000) .setfastestinterval(500) .setpriority(locationrequest.priority_high_accuracy); supportmapfragment supportmapfragment = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map); googlemap = supportmapfragment.getmap(); googlemap.setmylocationenabled(true); } @override public void onlocationc

android - getActionBar returning null -

this question has answer here: getactionbar() returns null (appcompat-v7 21) 4 answers i have activity and have added setsupportactionbar(toolbar); and want display home button on action bar. home button android predefined. and calling method getactionbar().setdisplayhomeasupenabled(true); but when run app, gives getactionbar retured null full code of activity following @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab); fab.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { snackbar.make(view, "replace own

java - JMockit throwing errors -

i'm trying mock interface class using jmockit, following example in documentation. however, im getting error saying java.lang.illegalargumentexception: matching real methods not found following mocks: package.jmockittest$1#httpresponse(package.httpclient client) @test public void mockinganinterface() throws exception { httpclient client = new mockup<httpclient>() { @mock string httpresponse(httpclient client) { return "100"; } }.getmockinstance(); weblogic weblogic = new weblogic(); assert.assertequals(client.httpresponse("asd"), "100"); } you passing string @ line client.httpresponse("asd"), "100" while mocked method expects httpclient need mock method, @mock string httpresponse(string client) { return "100"; } in mockup or you need change call use httpclient instead of string

windows - Cannot run python server using batch file -

here commands in batch: d: cd d:\startup\venv\scripts activate cd d:\startup\ python manage.py runserver commands after "activate" not executed reasons. tried put "cmd /k activate" instead "activate" result still same except command line still open. wrong here i suppose activate batch file , therefore needed is: cd /d d:\startup\venv\scripts call activate.bat cd d:\startup python.exe manage.py runserver without command call processing of batch file continues on other batch file without returning reason why last 2 lines never executed. run in command prompt window call /? , read output , more details see example answer on how call batch file in parent folder of current batch file? command cd parameter /d makes possible change directory , drive @ same time cd /? executed in command prompt window explains. in batch files advisable specify batch files , executables file extension.

android - Static ViewHolder and getting context when using with RecyclerView -

i'm trying use recycler view , handle on click event. i've read various methods of handling onclick event on recycler view item : define click listener inside view holder class itself. define click listener in oncreateviewholder(). define interface , go there (seems work). so first question option better? i'm using first method , if defining click listener in view holder class way go, how use context adapter view holder class static. basically, want have static view holder , on click event, open new activity need context. update : adding adapter , viewholder code. public class myadapter extends recyclerview.adapter<myadapter.viewholder> { private context mcontext; private list<job> jobs; public myadapter(context context, list<job> jobs) { mcontext = context; this.jobs = jobs; } @override public myadapter.viewholder oncreateviewholder(viewgroup viewgroup, int i) { view itemlayoutview = layoutinflater.from(viewgroup.getcontex

eclipse - Google App Engine (GAE) WEB-INF/lib order -

hey guys i'm working on project google app engine. data devices we're using mqtt. org.eclipse.paho.client.mqttv3.* library starts thread "client.connect()". after researches found cant create threads when working gae. following error shown: java.security.accesscontrolexception: access denied ("java.lang.runtimepermission" "modifythreadgroup") so continued searching , told use following code instead of "normal" thread: thread monitoringthread = threadmanager.createthreadforcurrentrequest( new runnable() {..} so decompiled paho library, looked thread created , changed it. created new class exported mymqttclient.jar in eclipse changed order of build @ properties -> java build path -> order , export mymqttclient.jar loaded before mqtt-client-0.4.0.jar use created function monitoringthread. but how can change order of .jar's in web-inf/lib ? thank answers, couldnt find useful until now. firstly there no need de

ios - Xcode 7 is using my framework after I deleted it -

i'm in process of developing framework. problem changes make framework not being reflected in app. app seems linked original framework created , isn't updating when update framework. when delete framework project, xcode still seems think it's there. setup created separate xcode project intending make app uses framework. copied root folder of framework project app project root folder , drag , dropped .xcodeproj app's xcode project. added framework nested xcode project in each of following steps: build phases>link binary libraries build phases>target dependencies general>embedded binaries i tried removing framework each of these locations. tried cleaning framework project , app project. tried deleting derived data in app project , framework project in window>projects tried using previous version of app project doesn't contain framework in way (not in xcode project or root folder) the ghost of framework continues haunt project! help?

linux - PHP YouTube Api V3 MaxResults Not Working -

i implemented google api app using youtube service youtube videos. works expected far getting results reason maxresults not working. display results if set example 15 shows endless number of results on page. <?php //load google api client //added google api support 01/21/2016 set_include_path(get_include_path().path_separator.'vendor/google/apiclient/src'); //================================================================================= //start google api integration //================================================================================= $htmlbody = <<<end <form method="get"> <div> search youtube video<br> <input type="search" id="q" name="q" placeholder="search" size="30"> </div> <input type="submit" value="search"> </form> end; if ( $_get['q'] )

powershell - Split column value in CSV file using multiple and duplicate delimiters -

i have csv file mess. i'm trying use regex extract first name , last name value in column in csv file. first , last names have own columns. the csv file (with different combinations of delimiters): id,description,number jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops,somevalue jdo,john doe - temp - client client ops ,somevalue jdo,john doe - temp - client client ops ,somevalue jdo,john doe-temp-client client ops,somevalue jdo,john doe - temp-client client ops,somevalue jdo,john doe - temp-client client ops,somevalue jdo,john doe-temp - client client ops,somevalue jdo,john doe - temp - cl

jquery - Waiting for multiple deferred objects to be finished and use the resolved values -

i trying figure out way wait multiple deferred objects , process them once done, may start next set deferred objects. i stuck because result of following not expected be. expecting result alldone resovled values 1,2,3 the actual result is alldone resovled values 1,2 var dfd1 = new $.deferred(); var dfd2 = new $.deferred(); var dfd3 = new $.deferred(); var dfds = [ dfd1, dfd2, dfd3 ]; var resolvedvalues = []; $.when.apply($, dfds).done(function() { dfds.foreach(function(dfd){ console.log("inloop"); dfd.promise().done(function(value) { resolvedvalues.push(value); }); }); console.log("alldone resovled values are" + resolvedvalues); }) dfd1.resolve(1); dfd2.resolve(2); dfd3.resolve(3); for why , see below. you're overcomplicating it. :-) callback give final promise when gives resolved values arguments: $.when.apply($, dfds).done(function(a, b, c) { // here, 1, b

c# - Use auto-generated classes/objects when using a SOAP WS in .NET? -

at current project have develop .net client application uses handful of soap web services communicate external software. fortunately .net makes easy use soap ws generates required objects when adding service reference. on other hand after playing around auto generated classes while i'm not sure if it's better use them directly in business logic or if should map them own models (e.g. using repository pattern). pros mapping: - separation of business logic , data access (ws change) - central point calls ws (can validate responses , proper error handling) - ws types cumbersome use (e.g. webservice1.typea not compatible webservice2.typea). - generated classes cannot/should not customized. - ... cons mapping: of used wsdls have complex structure , lots of nested types. in case of mapping them own models have duplicate many classes , properties. that's fact why have concerns solution. in short i'm unsure if duplication of web service classes own nam

How to return a Range of Int in Swift? -

how can return range of int function in swift? i've searched swift 2.1 docs, web, so, , tried: func myfunc() -> range { // } func myfunc() -> ( int ... int ) { // } func myfunc() -> range< int > { // } ... , many others ... sorry being bone-headed here, , in advance! your third 1 correct. compiles , works, example: func oneto10() -> range<int> { return 1...10 }

php - How to sum value of array if some values are same? -

i have following array array ( [0] => 1995,17500 [1] => 2052,17500 [2] => 2052,17500 [3] => 2236,30000 [4] => 2235,15000 [5] => 2235,40000 ); i have exploded value comma ,. foreach($array $key=>$value) { $newar = explode(',', $value); } so have similar first value i.e $newar["0"]. example 2235 , 2052. , have sum of second value i.e $newar["1"]. how can achieve following result php. array ( [0] => 1995, 17500 [1] => 2052, 35000 [2] => 2036, 30000 [3] => 2235, 55000 ) you can create new array key/index based , use array_key_exists check if key exists. if sum value, if not create key. not exact result want, it's neater. $newar = []; //new array foreach($array $value) { $explarr = explode(',', $value); if(array_key_exists($explarr[0], $newar)){ //check if key exists $newar[$explarr[0]] += $explarr[1]; //sum value existing key

jquery - Duplex WCF Service call using javascript (AJAX) -

now working wcf rest service now trying wcf duplex communication in wcf rest service currently calling service through jquery ajax , getting response it like this: $.ajax({ type: vartype, //get or post or put or delete verb url: varurl, // location of service data: vardata, //data sent server contenttype: varcontenttype, // content type sent server datatype: vardatatype, //expected data format server processdata: varprocessdata, //true or false crossdomain: true, cache: varcache, timeout: 200000, success: function (response) {// when service call success var names = response.d; alert(names); }, error: function (xhr) {// when service call fails alert(xhr.responsetext); } }); but in duplex communication there call contract in service service communicate later client. how can response of call contract in jquery ajax

MySQL Transaction -

it dumb question, , tried search , found nothing. i been using mysql years(not long) never had tried mysql transactions. question is, happen if issue insert or delete statement multiple clients using transactions? lock table , prevent other client perform there query? happen if other client issue transaction query while other client still have unfinished transaction? i appreciate come. p.s. use insert using file or csv big chunk of data or small one. mysql automatically performs locking single sql statements keep clients interfering each other, not sufficient guarantee database operation achieves intended result, because operations performed on course of several statements. in case, different clients might interfere each other. source: http://www.informit.com/articles/article.aspx?p=2036581&seqnum=12

c++ - Qt Creator - SFML Link to a console project -

Image
i working on project in console mode in wish implement sound. our choice turned sfml, install , use on os x. however, need make compatible qt project rendering, generate a.profile , integrate our code , library. in os x, no problem, installation , use possible. however, project, need integrate code make archive. every attempt link our project aforementioned library, run errors. could tell files included in project? working on protecting machines, cannot install packages. here screen of integration window, button exhilarating. cannot select library. you have use external library instead of internal.

hsm - Working with split secret key -

i need import splits of secret key hsm device. key encryption key (kek) 3des key has been split transport , need recombined in destination hsm. how can done ? splits being recombined in hsm itself, or being recombined outside of hsm , result imported hsm ? thank ! if key parts available outside of hsm you'd xor values , set key. use ckm_xor_base_and_data or possibly proprietary command well. ckm_xor_base_and_data requires @ least 1 key present. use combine keys sequentially, of course, if want holder different parts not able view other parts. note assume here keys have been split using t = n key sharing using xor. in principle of secret sharing have been used.

mysql - After login in to the profile how to insert some other columns data into same database in php -

i have signup form. once create form data inserted registered table once after login form need fill details , insert same columns comparing mail ids. when i'm trying insert data showing not inserted database. dashboard.php: <form method="post" action="personalinfo.php" id="myform"> <input type='hidden' value="<?php echo $_get['email'];?>" name='email'> <div> <label for="first-name">first name<span class="mandatory">*</span></label> <input id="first-name" type="text" name="first-name" value="" /> </div> <button type="submit" id = "submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> save</button> personalinfo.php: <?php $connection =

node.js - Error while running js file via node -

i trying run koa app.js file not work. here's app.js var koa = require('koa'), monk = require('monk'), wrap = require('co-monk'); var db = monk("mongodb url here"), collection = db.get('mycollection'), transactions = wrap(collection); var app = koa(); app.use(function*(){ var res = yield transactions.find({}); console.log(res); }); app.listen(3000); and here's error got: typeerror: cannot read property 'name' of undefined @ makeskinclass (/home/ric/node_modules/mongoskin/lib/utils.js:33:43) @ object.<anonymous> (/home/ric/node_modules/mongoskin/lib/grid.js:6:35) @ module._compile (module.js:398:26) @ object.module._extensions..js (module.js:405:10) @ module.load (module.js:344:32) @ function.module._load (module.js:301:12) @ module.require (module.js:354:17) @ require (internal/module.js:12:17) @ object.<anonymous> (/home/ric/node_modules/mongoskin/lib/db.js:22:16) @ module._compile (module.js:398

cloudera cdh - Oozie Shared Lib: where to place jars -

i have installed cloudera cdh quickstart vm 5.5, , i'm running sqoop action in oozie workflow. encountered error says mysql jdbc driver missing , came across answer here says mysql-connector-java.jar should placed in oozie's hdfs shared lib path, under sqoop path. when browse oozie's hdfs shared lib path, however, i've noticed 2 sqoop subdirectories copy jar. /user/oozie/share/lib/sqoop and /user/oozie/share/lib/lib_20151118030154/sqoop aside sqoop , hive , pig , distcp , , mapreduce-streaming paths exist on both lib , lib/lib_20151118030154 . so question is: place connector jar: on first or second one? what's difference (or difference of purpose) of these 2 paths in relation jars of sqoop , hive , pig , distcp , , mapreduce-streaming oozie? the lib_20151118030154 sub-dir current version of sharelibs, of 18-nov-2015. versioning allows make updates without stopping oozie service -- check documentation here . in other words: oozie

php - Add characters counter to wordpress title and excerpt -

i want create counter @ bottom of fields post title , post excerpt, when user exceed limit, should alert ("you put more characters recommended!"), can decide ignore alert , keep typing. didn't find solution in web match requirements. open functions.php file in theme’s directory , paste @ end code below: <?php function my_title_count(){ ?> <script>jquery(document).ready(function(){ jquery("#titlediv .inside").after("<div style=\"position:absolute;top:40px;right:-5px;\"><span>max 70 characters:</span> <input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"title_counter\" readonly=\"\" style=\"background:none;border:none;box-shadow:none;font-weight:bold; text-align:right;\"></div>"); jquery("#title_counter").val(jquery("#title").val().length); jquery("#title").keyup( function() {

javascript - How to update view? (angular2) -

i have input <input type="text" [ngmodel]="name" (ngmodelchange)="name=$event"> and this.name = 'adam'; when new name backend , this.name = res.data , input value on page doesn't change. why? try one. <input type="text" [(ngmodel)]="name"> if not working check class definition.

PHP file uploads doesnot read $_FILES['image'] -

this question has answer here: why $_files empty when uploading files php? 20 answers i have input type <input class="btn btn-success" type="file" name="profile_image" style="margin-top:10px; margin-left:20px;"></input> user add image file here, , php code upload file if(isset($_files['profile_image'])) { $image_type = $this->getimagetype($_files['profile_image']); if($image_type == 'image') { $extension = pathinfo($_files['profile_image']['name'], pathinfo_extension); $filename = '123_'.uniqid().'.'.$extension; move_uploaded_file($_files['profile_image']['tmp_name'], '../functions/images/images/'.$filename)

web applications - Tomcat - Maven plugin: run webapps but not current project -

the tomcat7-maven-plugin allows running current project web application , additional <webapps> can specified simultaneously loaded tomcat. my project not web application, accesses services provided webapps. how possible deploy number of webapps without running project webapp? following maven snippet results in filenotfoundexceptions because context.xml cannot found. <plugin> <groupid>org.apache.tomcat.maven</groupid> <artifactid>tomcat7-maven-plugin</artifactid> <version>2.0</version> <executions> <execution> <id>run-tomcat</id> <phase>${tomcat.run.phase}</phase> <goals><goal>run-war-only</goal></goals> <configuration> <webapps> <webapp> <contextpath>/my/app1</contextpath> <groupid>...</groupid> <artifactid>...</artifactid>

express - Indention error in jade -

this jade template. when try test following jade code @ http://jade-lang.com/ shows indention error html(ng-app='testapp2', lang='en') head(ng-app = testapp2) script(src='//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.15/angular.min.js') title!= title body(ng-controller = 'maincontroller vm') script(type='text/javascript', src='/assets/js/app.js') {{ vm.massage }} ul li(ng-repeat='person in vm.person') {{person.name}} after run app following error shows jade:8 6| script(type='text/javascript', src='/assets/js/app.js') 7| {{ vm.massage }} > 8| ul 9| li(ng-repeat='person in vm.person') 10| {{person.name}} unexpected token "indent" your li should lie inside ul html(ng-app='testapp2', lang='en') head(ng-app = testapp2) script(src='//cdnjs.cloudflare.com/a