Posts

Showing posts from June, 2011

ssl - JavaMail (SMTPS) + Grizzly, handshake failure -

i'm trying test own implementation of smtp server made on top of grizzly framework , struggling handshake problem during checking smtps support of javamail. found similar problem handshake (or not me) don't use client mode grizlly sslengineconfigurator, guess root of problem should different. code grizzly ssl configuration initialization (in integration test) looks following: try (inputstream keystorestream = transportencryptionit.class.getresourceasstream("server_keystore.jks")) { sslcontextconfigurator sslcon = new sslcontextconfigurator(); sslcon.setsecurityprotocol("tlsv1.2"); sslcon.setkeystoretype("jks"); sslcon.setkeystorebytes(ioutils.tobytearray(keystorestream)); sslcon.setkeystorepass(""); sslconf = new sslengineconfigurator(sslcon, false, false, false); } i install sslfilter filterchain (with server ssl config) immidiatly after transportfilter (which first filter in chain). filterchai

Curl output to display in the readable JSON format in UNIX shell script -

Image
in unix shell script, when execute curl command, curl result displayed below redirecting file: {"type":"show","id":"123","title":"name","description":"funny","channeltitle":"ifood.tv","lastupdatetimestamp":"2014-04-20t20:34:59","numofvideos":"15"} but, want output put in readable json format below in file: {"type":"show", "id":"123", "title":"name", "description":"funny", "channeltitle":"ifood.tv", "lastupdatetimestamp":"2014-04-20t20:34:59", "numofvideos":"15"} pls suggest try doing : curl ... | json_pp or jq using identity filter : curl ... | jq '.' or nodejs , bash : curl ... | node <<< "var o = $(cat); console.log(json.stringify(o, null, 4));"

How can I catch ALL errors in PHP? -

i've found lot of attempts @ all-inclusive error handling implementations, , figured might write wiki-style provide complete solution came with. the question is: "how might 1 catch, handle, or intercept error types in php?" now - might deemed 'rewrite' - don't know there's been comprehensive solution proposed. there 3 kinds of error handlers need: set_exception_handler , catch otherwise uncaught exceptions. set_error_handler catch "standard" php errors. first check against error_reporting see if it's error should handled or ignored (i ignore notices - bad that's choice), , throw errorexception , letting exception handler catch outputting. register_shutdown_function combined error_get_last . check value of ['type'] see if e_error , e_parse or fatal error types want catch. these bypass set_error_handler , catching them here lets grab them. again, tend throw errorexception , errors end being handled same

list - Editing a MultiString Array for a registry value in Powershell -

how create new multistring array , pass registry remotely using powershell 2.0? #get multiline string array registry $regarry = (get-itemproperty "hklm:\system\currentcontrolset\control\lsa" -name "notification packages").("notification packages") #create new string array [string[]]$temparry = @() #create arraylist registry array can edit $temparrylist = new-object system.collections.arraylist(,$regarry) # remove entry list if ( $temparrylist -contains "enpasflt" ) { $temparrylist.remove("enpasflt") } # add entry if ( !($temparrylist -contains "enpasfltv2x64")) { $temparrylist.add("enpasfltv2x64") } # convert list multi-line array not creating new lines!!! foreach($i in $temparrylist) {$temparry += $1 = "\r\n"]} # remove old array registry (remove-itemproperty "hklm:\system\currentcontrolset\control\lsa" -name "notification packages").("notification pack

Public/Private struct in Rust -

i have little project , want encapsulate struct's fields , use implemented methods. ├── src ├── main.rs ├── predator └── prey ├── cycle.rs └── mod.rs cycle.rs struct prey { name: string, } impl prey { pub fn new(n: string) -> prey { prey { name: n } } pub fn get_name(&self) -> &str { self.name.as_str() } } i'd leave prey private. main.rs use prey::cycle::prey; mod prey; fn main() { let pr = prey::new("hamster".to_string()); println!("hello, world! {}", pr.get_name()); } i error: error: struct `prey` private i know if put pub before struct prey {} , i'll expected result. grateful explanation, how, why not and/or best practices. visibility works @ module level. if want module x have access item in module y, module y must make public. modules items too. if don't make module public, it's internal crate. therefore, shouldn't worry making items in

Getting methods to work in a simple Java program -

i've got of program working apart few bits aren't, i'm new java it's not obvious i'm meant do. here methods: public string getinventorycode() { return inventorycode; } public int getquantityinstock() { return quantityinstock; } public int getdailydemand() { return dailydemand; } public int getreorder() { return reorder; } public int getleadtime() { return leadtime; } public int newdeliveryin(int newdeli) { quantityinstock += reorder; return newdeli; } here main code: stockitem item_1 = new stockitem("a654y", 1000, 50, 500, 13); int quantityin = item_1.getquantityinstock(); (int n = 1; n <=50 ; n++) { quantityin -= item_1.getdailydemand(); system.out.print(n + "\t"); system.out.println(quantityin); if (n % item_1.getleadtime() == 1 ){ system.out.println("batch ordered"); } else if (n % item_1.getleadtime() == 0){ quantityin += item_1.getr

java - Transfer portion of large file from server via SSH -

for our applications, log files on several different remote servers depending on environment. although rollover daily, envs, logs can grow large (typical high-traffic environment has logs reach 10 gb daily). basically i'm trying achieve functionality similar unix less command jump last line of file , read newest portions. i started jsch in java worked small files, skip end minus set number of bytes , create new file last portion of log. code looks this: session session = createjschsession(user, pass, host, port); channelsftp sftpchannel = createsftpchannel(session); long filesize = getfilesize(sftpchannel, path); inputstream in = sftpchannel.get("/path/to/file/hello.log"); in.skip(filesize - bytestoread); however larger files, execution time no better if i'd transferred file whole. after timing determined skip method culprit, seems call in.read() n times. the question is, how transfer small chunk of text file remote server? i'm not dead-set o

android - Emulator crashing (NullPointerException) only on one computer when calling imageView.getDrawable() -

when run app on emulator on 1 of laptops, returns null imageview.getdrawable() if run same app/code on laptop's emulator, runs without issue , if run on actual device, runs without issue. this code: if ( !(imageview.getdrawable() instanceof bitmapdrawable)) return; //clean free memory bitmapdrawable bitmapdrawable = (bitmapdrawable)imageview.getdrawable(); //this throws null pointer (which means above line returned null) bitmapdrawable.getbitmap().recycle(); throws this: java.lang.nullpointerexception @ com.bignerdranch.android.criminalintent.pictureutils.cleanimageview(pictureutils.java:54) @ com.bignerdranch.android.criminalintent.crimefragment.onstop(crimefragment.java:251) @ android.support.v4.app.fragment.performstop(fragment.java:1677) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:994) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1121) @ android.supp

javascript - Bootstrap popover destroy & recreate works only every second time -

i want programmatically destroy & recreate specific bootstrap popover. is: $('#popoverspan').popover('destroy'); $('#popoverspan').popover({placement : 'bottom', trigger : 'hover', content : 'here is!'}); and works every second time only. thought it's matter of time takes destroy popover, adding delay between 2 lines doesn't help. recreated problem in jsfiddle: http://jsfiddle.net/lfp9ssd0/10/ why that? has been suggested works, e.g. in twitter bootstrap popover dynamically generated content via ajax , bootstrap popover reinitialization (to refresh content) it works fine when skip destroying, not sure happens when create popover element without destroying existing one. reinitialised or create new popover losing access old one? solved myself. apparently .popover('destroy') asynchronous, , immediate creation of popover fails, while previous 1 being destroyed. tried adding delay using alert , failed

ios - Passing user data through view controllers -

this question has answer here: passing data between view controllers 35 answers i'm making basic app allows user login. i wanted know general practice of passing user data between view controllers. after user authenticated, acceptable pass data through view controllers? for example, user logged in , authenticated. user wants "create event", able save user hosting event, have store users id on event host , need access uid. save users id after login , keep passing in every view? i using firebase backend if helps. you should learn thing called "segues". primary mechanism transition between views in ios. here's tutorial(no personal affiliation, btw) http://makeapppie.com/2014/07/01/swift-swift-using-segues-and-delegates-in-navigation-controllers-part-1-the-template/ haven't used firebase, if passing event data scratch 4

make an array of dictionary in plist swift -

i trying create plist this... using code objective-c translated swift... unfortunately array empty remains what wrong? in advance! <plist version="1.0"> <array> <dict> <key>uscita_ore</key> <string>18</string> </dict> <dict> <key>uscita_ore</key> <string>17</string> </dict> </array> </plist> var paths = nssearchpathfordirectoriesindomains(nssearchpathdirectory.documentdirectory, nssearchpathdomainmask.userdomainmask, true) nsarray var documentsdirectory:anyobject = paths[0] var path = documentsdirectory.stringbyappendingpathcomponent("orari_marcate.plist") var filemanager = nsfilemanager.defaultmanager() var fileexists:bool = filemanager.fileexistsatpath(path) var lista_marcate : nsmutabledictionary? var ma

objective c - Different Font Styles in a String in an Array -

let's have this: self.dictionary = [nsmutablearray arraywithobjects: @"blah", @"blah", @"blah (blah)", @"blah", @"blah", nil]; in third object, want have first "blah" larger font-size , black font-color. however, want second "blah" parentheses of smaller size , grey color. how go doing this? possible? you want use nsmutableattributedstring . you concatenate yours strings , each substring, figure attributes want, call - setattributes:range: .

javascript - Math.log, a Natural logarithmic y scale for currency time-series? -

my attempts make y values scale logarithmic turning data upside-down. i have vanilla js code , every implementation read tied in huge libraries of production code, not sure how/what extract, need guidance not put finger on problem weather sum or miss-use of math functions. i testing drawing y 'data' canvas (no libraries used) x axis constant 2px difference math.log uses e (2.718) default base have read.. should seeing price data on natural log scale wont work. function logscale(data){ var log=data.slice(0); var i=log.length; while(i--){ log[i]=math.log(data[i]); // should natural don't see change // log[i]=math.pow(math.log(data[i]),10); //upside-down // log[i]=math.log(data[i])/math.ln10; //no visible change when drawn canvas } console.dir(log); return log; } another attempt couple of weeks ago using data min, max , difference. removing infinity. function ᐥlogarithm(data){ var lmax,lmin,l

javascript - Send HTTP Basic-Auth header info while submitting pdf to webserver -

i'm looking sample how send http basic-auth header info part of pdf submit via javascript. i found following sample javascript code 1 of itext pdf examples: this.submitform({ curl:"http://itextpdf.com:8080/book/request", csubmitas: "html" }); are there other options send http username:password part of submitform() method? thanks help. i'm not expert on using forms pdfs, gather api documentation (page 345) , responses on adobe's forum doesn't possible. you may take net.http.request though, 1 have oauthenticate argument (page 550 on api 8.1 documentation or here api 9.1) allow pass user , password http authentication or show dialog user can type in -- can modify http header. performing post request way appropriate orequest (probably) end having result looking for. note: realised pdf citing sdk 8.1, sdk 9.1 doesn't show authentication parameter submitform method either though.

jquery - parallax scrolling - jumps when used mouse scroll wheel -

i have come across problem parallax scrolling. when mouse scroll wheel used starts jumping , bad on chrome , little jump in ie fine in firefox. here link site . the code using parallax <script> var topdiv = document.getelementbyid("topdiv"); var speed = 1.5; window.onscroll = function() { var yoffset = window.pageyoffset; topdiv.style.backgroundposition = "center "+ (yoffset / speed) + "px"; scrolling = true; } </script> if can me have looked answers not able find. thanks in advance this known issue... check parallax site on chrome mouse , jump. there workaround seems work me: use nicescroll plugin don't use default scroll... i used here: http://www.xboxeventsus.com/ here link nicescroll plugin: http://areaaperta.com/nicescroll/

hiveql - hive-site.xml path in hive0.13.1 -

i'm newbie. know hive-site.xml , hive-default.xml files locations in hive-0.13.1 version. i have downloaded hive0.13.1-bin version below location. http://apache.mirrors.pair.com/hive/hive-0.13.1/ extracted , configured hive environment variables. i'm able run commands (create table, show, load data, query table..) . but in conf(/hive/hive-0.13-1/conf) directory, not see hive-site.xml , hive-default.xml files. where these files located in hive-0.13.1 version? follow steps 1) extract folder 2)go /apache-hive-0.13.1-bin/conf , make copy of hive-default.xml.template , looks hive-default.xml (copy).template. 3) rename hive-default.xml (copy).template hive-site.xml. 4) make copy of hive-env.sh.template hive-env.sh. add in hive-env.sh export hadoop_heapsize=1024 # set hadoop_home point specific hadoop install directory export hadoop_home=/home/user17/bigdata/hadoop #hive export hive_home=/home/user17/bigdata/hive # hive configuration director

java - Does postDelayed cause the message to jump to the front of the queue? -

i looking on android docs postdelayed post delayed documentation this similar question - https://stackoverflow.com/questions/25820528/is-postdelayed-relative-to-when-message-gets-on-the-queue-or-when-its-the-actual - had while different situation(and worded lot clearer in mind) basically heres docs method - "causes runnable added message queue, run after specified amount of time elapses. runnable run on user interface thread." i know every thread has message queue, looper , handler associated it. - what relationship between looper, handler , messagequeue in android? . in terms of "to run after specified amount of time elapses", if pass in 0 argument delaymillis , there still messages in message queue, message 0 skip on rest of messages(that in front of it) in message queue directly handled looper? know looper dispatch message handler's handlemessage() method- how looper knows send message handler? . test on own don't know how go it. the

Kentico 7 error Type or Namespace WorkflowManager could not be found -

i trying setup kentico 7 patch 58 site. downloaded kentico installation manager 7 , created new site. when access site error compiler error message: cs0246: type or namespace name 'workflowmanager' not found (are missing using directive or assembly reference?) source error: line 16: protected treeprovider mtreeprovider = null; line 17: protected workflowstepinfo mworkflowstepinfo = null; line 18: protected workflowmanager mworkflowmanager = null; please advise missing here. you using web application project type , didn't rebuild project after applying hf. please refer to: c:\program files (x86)\kenticocms\7.0\hotfix70_58\instructions.pdf (page 7) also @ page 12 (additional notes , workarounds) , check whether there manual steps have take.

Running Windows batch files from Emacs -

i'm new gnu emacs, , perhaps noob question, have few batch files use lot when coding in emacs compile/build/execute/debug/etc. wondering how a) run these batch files emacs without having keep opening cmd prompt window or going windows explorer , b) bind key shortcut (perhaps specify file?) have seen several things online running emacs in batch-mode, don't believe i'm looking for. , know possible because have seen others run batch emacs (output , appear in new buffer adjacent current if did c-x 3 ) thanks in advance! to run arbitrary shell command in emacs, call shell-command bound m-! see c-h f shell-command (or c-h k m-! ) details. i believe in windows-native emacs, default shell cmd (or alias thereof), i'm reasonably confident you're thinking of. i'm not sure whether of following work in windows, related commands are: m-& - async-shell-command m-| - shell-command-on-region and prefix argument (e.g. c-u m-! ) of commands in

ios - Make periodic server requests with NSURLSessionDataTask and dispatch_source timer -

need , explanation, because i'm stuck in question. need make this: 1) make 1 request server, response , want make request every 7 seconds(example). response. if satisfy several conditions -> stop timer , stuff. main problem timer never stops, despite fact in response right. assume use gcd incorrectly. because in debug code behaves strange. what have done: this request function(it became after read 50 links how similar things) -(void)makerequestwithurl:(nsstring*)urlstring andparams:(nsstring*)params andcompletionhandler:(void(^)(nsdictionary *responsedata, nserror *error))completionhnadler{ nsurlsessionconfiguration *configuration = [nsurlsessionconfiguration defaultsessionconfiguration]; nsurlsession *session = [nsurlsession sessionwithconfiguration:configuration]; nsurl *url = [nsurl urlwithstring:urlstring]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:url cachepolicy:nsurlrequestusepr

java - NoSuchMethodException while calling GeometryJSON().read() -

i using jts (from vividsolutions) , geotools. have following code: public geometry jsontogeom(string json) throws ioexception { geometry obj = new geometryjson().read(json); return obj; } however, returns following runtimeexception: java.lang.runtimeexception: java.lang.nosuchmethodexception: org.geotools.geojson.feature.featurehandler.<init>(com.vividsolutions.jts.geom.geometryfactory) @ org.geotools.geojson.delegatinghandler.createdelegate(delegatinghandler.java:130) @ org.geotools.geojson.geom.geometryhandler.primitive(geometryhandler.java:68) @ org.json.simple.parser.jsonparser.parse(unknown source) @ org.json.simple.parser.jsonparser.parse(unknown source) @ org.geotools.geojson.geojsonutil.parse(geojsonutil.java:236) @ org.geotools.geojson.geom.geometryjson.parse(geometryjson.java:655) @ org.geotools.geojson.geom.geometryjson.read(geometryjson.java:196) @ am.abhi.experiments.geotoolstest.geojson.jsontogeom(geojson.java:13) @ am.abhi.experiments.geotoolstest

python - Django Rest Framework filtering a many to many field -

i filter serialization of many many field, don't need create view or generic view explained here because need use data in view. the code pretty simple. locations in model si manytomany field. class serviceserializer(serializers.modelserializer): locations = locationserializer(many=true) # [...] class meta: model = service and locationserializer is: class locationserializer(serializers.modelserializer): # [...] class meta: model = locationaddress # [...] i locations serialized based on boolean field in model. active=true . how can that? if not need locations field within serializer writable, may benefit dropping serializermethodfield . other option dynamically remove locations field when serializing individual object, create inconsistent output if multiple objects returned not have same active flag. to serializermethodfield , add new method on serviceserializer . class serviceserializer(serializers.modelseri

How do I get a string from string.xml in Java using Android SDK? -

before ask, i've looked @ this post , tried suggestions no avail. problem can set string using getresources().getstring(r.string.example) within oncreate method, want set public static final string value in string.xml using same getresources() method. but, when this, "cannot make static reference non-static method getresources() type contextthemewrapper". tried instantiating contextthemewrapper , also this.getresources().getstring(r.string.example) which both clear error, both crash nullpointerexception. solution set string resource appreciated. so far have this: public class mainactivity extends activity { contextthemewrapper contextthemewrapper = new contextthemewrapper(); public final string cypher = contextthemewrapper.getresources().getstring(r.string.cypher_txt); public static final int layers = 7; public static final int flip = 3; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedin

c++ - Makefile:7: target ( given more than once in the same rule -

im not familiar make system. when tried execute program below, there no problem: ./prog.out arg1 arg2 arg3 when decided make, added following script makefile parse ${parameters}: ./prog.out ${parameters} its strange when works well; make parse parameters="aaa bbb ccc" and these characters: '(' , ')' generates errors! make parse parameters="( d , ( d , ( d , d ) ) )" makefile:7: target `(' given more once in same rule. makefile:7: target `d' given more once in same rule. makefile:7: target `,' given more once in same rule. makefile:7: target `(' given more once in same rule. makefile:7: target `d' given more once in same rule. makefile:7: target `,' given more once in same rule. makefile:7: target `d' given more once in same rule. makefile:7: target `)' given more once in same rule. makefile:7: target `)' given more once in same rule. ./prog.out ( d , ( d , ( d , d ) ) ) /bin/sh: 1: syntax

c# - Can't add a service reference on home computer -

Image
i'm working on project few colleagues , i'm creating own service. whenever try add service reference project fails. here service wish add after i've double clicked in services list: ... , here rather unhelpful error when open url in chrome. it's fresh pull , adding services worked on university computer. i've tried disabling firewall read on msdn network no avail. i'm using .net 4.5 you may need register .net 4.5 iis, try register it check below post similar issue note below question related .net 4.0 could not load type 'system.servicemodel.activation.httpmodule' assembly 'system.servicemodel

ios - Issue with Apple Pay / Stripe integration -

i have followed stripe's documentation , example app on integrating apple pay. in handlepaymentauthorizationwithpayment method, under createtokenwithpayment, getting error: error domain=com.stripe.lib code=50 "your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios ." userinfo=0x170261b40 {com.stripe.lib:errormessagekey=your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios ., nslocalizeddescription=your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios .} anyone know how resolve this? using latest stripe library. thanks. this little bit of rnd helped me. digging customs

php - Using find with phpQuery -

i have started using phpquery, , documentation isn't particularly , not been able find many examples on web. i wanted pass html phpquery , match string. ie. $html = '<div>blah blah blah <a href=1.php>xssss</a></div>'; and here want search $html 1.php if found should return text "found it" i tried doesn't work: $doc = phpquery::newdocumenthtml($html); if(pq($doc)->find('12.php')) { echo 'found it'; }else{ echo 'not found'; } as output on 'found it'. thanks in advance

facebook - How to confirm Android Share Intent is successful or complete -

is there way confirm if share intent in android successful or unsuccessful? (for example, if share facebook post, i'd know if posted or know if cancelled.) below android intent code use share. currently, launches dialog allow user choose app share to: intent shareintent = new intent(android.content.intent.action_send); shareintent.settype("text/plain"); shareintent.putextra(android.content.intent.extra_subject, subject); shareintent.putextra(android.content.intent.extra_text, body); activity.startactivity(intent.createchooser(shareintent, title)); personally, "use startactivityforresult() " , check gets returned. however, can read more here , it's not simple that. if intent cancelled user, same number returned if intent completed (for appications). ultimately, @ moment simpler share intent in general , cannot check if it's successful or not.

email - How to use applescript to tell Mail to keep a copy of sent message -

i use applescript , can send messages without problem, "sent" box not copy of sent. however, if use mail application send messages, "sent" box gets copy of sent. guess applescript may miss command or tell mail keep copy of sent messages. what's command missed? thanks. tell application "mail" set thenewmessage make new outgoing message properties {subject:thesubject, content:thebody & return & return, visible:true} tell thenewmessage set visibile false set sender thesender make new recipient @ end of recipients properties {address:theaddress} make new attachment properties {file name:theattachment}

Accesing two different rows simultaneously in C -

suppose have data set arranged in following way 19 10 1 1 12 15 1 1 13 12 4 5 10 5 2 3 ... and on, @ particular iteration in loop have read 1st , 4th row , in next iteration have access other set of rows,for example 1st iteration: 1st row: 19 10 1 1 4th row: 10 5 2 3 i access data using fscanf() function. how ensure choose 1st , 4th rows or 2 rows matter @ given iteration? (i have not considered reading 2d array since size of data set 10^8 ) thank you. as read through data (say, stored in standard file), byte offsets rows looking row delimiters (a newline character). can read out rows based on start , end byte offset c pointer arithmetic on file * , fseek() . storing few byte offsets (an 8 byte long or equivalent, often) cheap.

java - Call a method of "Activity extended" class from "ListActivity extended" -

here snippet of "mybaseactivity" class. public class mybaseactivity extends activity { public void resetdisconnecttimer() { disconnecthandler.removecallbacks(disconnectcallback); disconnecthandler.postdelayed(disconnectcallback, disconnect_timeout); } @override public void onuserinteraction() { resetdisconnecttimer(); } } my app contains many classes extend "activity" , couple of others extend listactivity. classes, extending activity, can extend "mybaseactivity" , call method as: @override public void onuserinteraction() { resetdisconnecttimer(); } but classes extending listactivity ? ideas how can solve ?? you can switch fragments so: class myactivity extends mybaseactivity { @override protected void onuserinteraction() {..} } class mybaseactivity extends fragmentactivity { protected void onuserinteraction() {...} } then

ios - How to check NSDictionary values are nil in iPhone -

i have 1 nsdictionary , in dictionary keys , values dynamically added.now want check if value nil set empty string key.how can check this? checking using conditions but, there simple way check nil or empty values.please me,thanks nsdictionary not hold nil values keys. if want test presence/absence of specific key's value, can use -objectforkey: . method returns nil if key/value pair absent. for "empty values", have expand on considered empty value in context of program (e.g. people use nsnull indicate empty value, or if working strings values empty string).

mysql - Multiple Aggregate with different Group By -

i have table user, company, parentcompany , table goal. each company have parentcompany, , each user inside 1 company. goal have number of action, , type of goal, user execute goal, , time executed. i want calculate number of action in date range each type of goal, each user, company, , parent_company. number of action each company equal sum of action user reside in company. more or less after join query, able table below, column id id of company, parent_id id of companyparent, , num number of goal user inside of id company. id parent_id num ----------- -------------------- ----------------------- 1 3 1 2 1 2 3 1 1 4 2 4 now want make below: id parent_id sum_id sum_parent ----------- -------------------- -------------- ------------- 1 3 1 1 2 1

mysql - SQL Select/Introduce adding new values after every 3 rows -

my requirement wanted give new values column after every 3 items/rows in table. db table this. a b c ---------- a1 b1 c1 a2 b2 c2 a3 b3 c3 a4 b4 c4 a5 b5 c5 a6 b6 c6 a7 b7 c7 i wanted add new column d new value changes every 3 rows view a b c d ------------ a1 b1 c1 d1 a2 b2 c2 d1 a3 b3 c3 d1 a4 b4 c4 d2 a5 b5 c5 d2 a6 b6 c6 d2 a7 b7 c7 d3 is possible sql select statement?

extjs4.1 - How to select multiple rows by using grid.getSelectionModel().select(Indexes) in extjs 4.1 -

i want select multiple rows using grid.getselectionmodel().select(indexes) in extjs 4.1 knows how it?? here code: var grid = ext.getcmp('gridstudents'); var fieldvalues = '2054,2055,2057'; var arr = fieldvalues.split(','); (var j = 0; j < arr.length; j++) { index = grid.store.find('studentid', arr[j]); grid.getselectionmodel().select(j); } first of selection model must have mode multi or simple . then can use method selectrange(startrow, endrow) when want select bunch of records in 1 block. you can use select , pass array of records or select 1 one using index. both function accepts parameter keepexisting . when set true, existing selection kept (as name suggests). also pass j select method instead of index . so easiest fix be: for (var j = 0; j < arr.length; j++) { var index = grid.store.find('studentid', arr[j]); grid.getselectionmodel().select(index, true); } if model configured mult

ios - Is it possible to store a music file in iPhone local storage? -

i making iphone app in user can listen stories present on web server. now want download audio story file local iphone memory on download button click. i downloading file webserver file saving somewhere else, not in phone memory. 1 know how can store file in iphone memory, not in application document memory? i think links idea document directory link1 link 2 here sample code snippet nsstring *filepath = [[self applicationdocumentsdirectory].path stringbyappendingpathcomponent:@"filename.caf"]; [filedata writetofile:filepath atomically:yes ]; - (nsurl *)applicationdocumentsdirectory { return [[[nsfilemanager defaultmanager] urlsfordirectory:nsdocumentdirectory indomains:nsuserdomainmask] lastobject]; }

java - YAJSW - Startup script to clear .lck files -

we use yajsw (11.08) wrap our java application service, when switching java 8, noticed if application did not terminate gracefully, .lck files generated logger, not cleared. we in process of switching new logger, in mean time need start script clear these .lck files. i read here yajsw supports shell , groovy scritps, answer this question answer claims supports groovy scripts. as far can tell need indicate state @ script executed, me assume it's start state. i have added wrapper.conf : wrapper.script.start=scripts/clean-up.bat what missing or doing wrong? running scripts not available in version i'm using? or shell scripts not supported? edit: updated yajsw version 11.11 (latest) - still not work run process console , see error messages get. running 11.11 java 8 , noticed though documentation specifies want this: wrapper.script.start=scripts/clean-up.bat yajsw looks in scripts directory default, , have make sure script in directory. can see file

Cannot Send Text along with Image to Server [android] -

hi how can send text message along image can upload image cannot send text @ once want send string user_id , project_id along this. help me please. private class uploadtask extends asynctask<bitmap, void, void> { protected void doinbackground(bitmap... bitmaps) { if (bitmaps[0] == null) return null; setprogress(0); bitmap bitmap = bitmaps[0]; bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.png, 100, stream); // convert bitmap bytearrayoutputstream inputstream in = new bytearrayinputstream(stream.tobytearray()); // convert bytearrayoutputstream bytearrayinputstream defaulthttpclient httpclient = new defaulthttpclient(); try { httppost httppost = new httppost( "http://61.19.244.132/upload.php"); // server stringbody user_id = new s

How do I convert date like '31/06/2013' or '30/02/2013' of datatype varchar in SQL Server 2008 -

i have column named next_due_date datatype varchar , in column non-existing dates 31/06/2012 or 30/02/2013 saved. because of error message when convert date datatype. the conversion of varchar data type datetime data type resulted in out-of-range value. if dates would valid (not 31st of june or 30th of february - dates don't exist!), use convert function convert them date : declare @datetable table (datecolumn varchar(20)) -- **valid** dates - 30th of june, 28th of feb insert @datetable(datecolumn) values ('30/06/2012'), ('28/02/2013') -- converted date type using style #104 select datecolumn, convert(date, datecolumn, 104) @datetable

ios - UIView in NSLayoutContraint does not conform to AnyObject in swift -

i have found question , answer here error type 'uiview!' not conform protocol 'anyobject' for ... @iboutlet var mainview: uiview! @iboutlet weak var contentview: uiview! ... nslayoutconstraint(item: self.contentview, ...` is there somthing happening dereferencing view object? i getting same error after copy-pasting , trying modify objective-c code swift project. realized had left relatedby 0 instead of nslayoutrelation.equal. after fixing error went away. weird compiler show error on first parameter when issue relatedby. hope helps.

javascript - Add minutes to while loop -

i trying make users end time add 30 mintues on , on over , display time function() { var totime = new date(result2); while (true) { var totime30 = new date(totime.gettime() + totime.gettimezoneoffset() *30 * 1000); var totime60 = new date(totime30.gettime() + 30 * 60 * 1000); var addmin = totime30 + "" + totime60; alert(addmin); break; } right code adds first ex 02:00 02:30 how keeps adding 30 minutes time? update var totime = new date(result2); while (true) { var icount = 0; var totime30 = new date(totime.gettime() + totime.gettimezoneoffset() *30 * 1000); var totime60 = new date(totime30.gettime() + 30 * 60 * 1000); var addmin = totime30 + "" + totime60 + (++icount); alert(addmin); break; }

ios - FBLoginView Button Tiling -

Image
i have implemented fbloginview on previous version of ios app, suited ios 6&7. recently, after ios 8 release, upgraded facebook framework latest version , below result of implementing same fbloginview button. i tried using previous version of facebook framework, still experience same problem. below implementation if fbloginview programmatically in code self.fbbtn = [[fbloginview alloc] init]; self.fbbtn.frame = cgrectzero; self.fbbtn.readpermissions = @[@"public_profile", @"email"]; self.fbbtn.delegate = [facebookdelegatehelper sharedobject]; [self addsubview:self.fbbtn]; [self.fbbtn settranslatesautoresizingmaskintoconstraints:no]; what doing wrong? the 1 work be: fbloginview *loginview = [[fbloginview alloc] init]; loginview.frame = cgrectmake(x, y, w, h); // fbbutton position loginview.delegate = [facebookdelegatehelper sharedobject]; [loginview siazetofit]; [self addsubview:loginview]; this should make button appear. rest of

Using mysql command line to generate CSV, can't generate it in any other directory except /tmp -

i creating csv , mysql dumps via mysql command line. creating mysql file can created .sql dump in required directory mysqldump -u"root" -p"root" dns packet --where="server_id=1 > /var/www/mydatafile/sqldata.sql that works okay in case of csv, creates files in tmp folder, can't create files in other location mysql -u"root" -p"" dns -e "select * outfile '/var/www/mydatafile/my_csv.csv' fields terminated ',' lines terminated '\r\n' tablename"; it says error 1 (hy000) @ line 1: can't create/write file '/var/www/mydatafile/my_csv.csv' (errcode: 13) i have given permission www directory still gives same error...may know reason behind not creating csv anyother location while sql can generated easily.. your directory /var/www/mydatafile/ has writable mysql user (usually mysql ). can check user in file my.cnf (in debian/ubuntu based, located in /etc/mysql/ ). the

asp.net - How actually Session works in MVC? -

i'm little-bit confused session management in mvc4. lets say, entered username , password , clicked on login button. on server side, got sessionid httpcontext.current.session. , validating user credentials against database. if user valid, adding sessionid, username , uiserid in session. lets say, next time request came same machine , same browser, got same sessionid , allowing user access other information. now have following questions: how server come know request came same browser , same machine? i found that, sessionid different different browser same same browser on different machine, if logged in machine1 , google chrome, possible use same session different browser?(means session available different machine same browser. possible?) how server understand request same user, logged in? in asp.net session maintained viewstate, view state not used in mvc, used in mvc? first suggest read this wikipedia article http sessions. answers on question: with ev

objective c - iOS spritekit nodes stutter when transitioning from scene -

i'm developing game in ios spritekit using objective c. created menu view in viewcontroller , i'm calling gamescene. in gamescene uses 5 different nodes has released 1 one randomly top of screen. each of 5 nodes have 4 different images stored in atlas. if node moves bottom of screen change image in node , release top of screen. i'm releasing node using following code self.wait = [skaction waitforduration: 1.0]; self.run = [skaction runblock:^{ if ([nodesarray count] > 0) { //select node release randomly , remove array } }]; self.seq = [skaction sequence: @[self.wait, self.run]]; those 5 nodes stored in array called nodesarray. code selecting random node : int = arc4random() %[nodesarray count]; skspritenode *mynode = nodesarray[i]; for removing node in array : [nodesarray removeobjectatindex:i]; after setting position : mynode.position = cgpointmake(x, y) and velocity : mynode.physicsbody.velocity = cgvectormake(dx,dy) and add node scene :

xcode - keyboard not appearing when clicking iOS input text field/view no matter where I put them -

hi reason in ios project on latest xcode6 keyboard refusing appear anymore when click inside input textfield or textview. i did have 1 of fields dismissing keyboard via .h iboutlet uitextfield *textfield; { } - (ibaction)dismisskeyboard:(id)sender; .m - (ibaction)dismisskeyboard:(id)sender { [textfield resignfirstresponder]; } but when delete code, tried deleting view controller files & storyboard , have tried dragging input textfield/view onto other view controllers/views , still refuses appear no matter put it! also tried doing clean, restarting xcode , mac itself. at moment don't have custom code in controller file .m or h. apart restarting project i'm not sure how default behaviour of keyboard appearing when clicking inside input back! the thing have been doing in other storyboard view controllers experimenting constraints/autolayout. scratching head, apart starting new project file i'm not sure do, great boss, go simulator-> select

web services - Getting not valid cvc-complex-type.2.4.d: Invalid content was found starting with element Employee. No child element is expected at this point -

i using webservices.using below xml code.i getting error below while running code. not validcvc-complex-type.2.4.d: invalid content found starting element 'employeeallergy'. no child element expected @ point. here's code: <employeeallergy> <allergyid>1020</allergyid> <allergytypeid>fdb</allergytypeid> <allergyseveritytypeid>mild</allergyseveritytypeid> <allergycomment>ssss</allergycomment> <onsetdate>20140317</onsetdate> </employeeallergy> any appreciated.

html - Javascript get ID of a child element using information about the parent -

i have div created using javascript. the div has varying number of child elements check boxes. i want retrieve id's of checkboxes using loop. the div has been passed through class using, , has been called: oinput i know working fine able retrieve number of child elements div has, using following line: oinput.childnodes.length but problem not know how retrieve id of child elements. want id's display in alert box now. so far have: for (var ii = 0; ii < oinput.childnodes.length; ii++) { var childid = oinput.childnodes[ii].id; alert("child " + childid); } but not correct solution. have searched around there not seem clear answer question anywhere. looking solution using javascript display answer in alert box in loop. this works me: <html> <body> <div id="oinput"> <input id="1" type="text"> <input id="2" type="text&qu