Posts

Showing posts from April, 2015

java - Can we create a common screen to handle all type of exceptions in Android? -

i thinking create mechanism handle type of exception , show common screen instead of error user of application. such type of handling possible in web development possible on android application development? i nice idea if don't need write code on each activity or screen handle type of exception. please suggest. in catch redirect caught exception desired activity exceptions described. match caught exception & done..

c# - linkbutton in gridview has different id and do postback event target it should be same? -

href="javascript:__dopostback(&#39;grid1$ctl02$lkbdelete&#39;,&#39;&#39;)" id="grid1_lkbdelete_0" full link is: <a onclick="javascript:return popupdialouge(&#39;&lt;b>are sure want delete record?&lt;/b>\nbecause process related comments record\nwill deleted.&#39;,&#39;confirmation&#39;,&#39;delete&#39;,&#39;cancel&#39;,this,&#39;ui-icon-alert&#39;);" id="grid1_lkbdelete_0" name="lkbdel" href="javascript:__dopostback(&#39;grid1$ctl02$lkbdelete&#39;,&#39;&#39;)">delete</a> actually want custom postback capturing eventargument here can event target should same event target different can't cause manual postback i did myself changed gridview clientid mode static auto replaced underscores _ linkbtn id doller $ worked. var ctlid=this.id.replace(/_/g,'$'); function postback(){ __dopostback(ctlid,'&

select - orientdb query edge property by value -

please excuse limited english. i'm using orientdb (community-2.0.9) , have 2 vertices: person , university , 1 edge: isstudent. edge isstudent has property 'mark' float. person --isstudent--> universtity wan't select persons, mark greater 3.0, got no results. but if query equality got 2 results. do have ideas how solve this? querys: select person out_isstudent.mark = 3.4 --> 2 results select person out_isstudent.mark > 3.0 --> no results best regards. if you: select out_isstudent.mark person you see returns list [3.4] instead of 3.4 the query should not work first since you're comparing [3.4] == 3.4 you can achieve want with: select person out_isstudent[0].mark > 3

javascript - jquery ui autocomplete displays only first item in db -

Image
am using jquery autocomplete on templete, results autocomplete displays 1 item despite results fetched have more 1 item. shows first item on list! example: if have result list ('type1', 'type2', 'type3') and on autocomplete type 't' displays type1 on drop down! i newbie in jquery kindly rectify mistakes( if any) my autocomplete code: $(".fro").each(function() { $(this).autocomplete({ source : function(request, response) { $.ajax({ serviceurl: '${pagecontext.request.contextpath}/index.htm', datatype: "json", paramname: "fro", delimiter: ",", data : { term : request.term }, success : function(data) { response($.map(data.result, function(item) {

php - Change values of custom option of product in magento 1.9 -

i added 2 custom options product in magento 1.9 . custom options are: title: shape sku: shape input type: drop-down values: rectangle, round, oval title: color sku: color input type: drop-down values: red, blue, green, white, black and these displayed in product page successfully. problem is when user select rectangle shape drop down second drop down, colors should load red, blue, green only. that depending upon values in shape drop down have change values in color drop down product. how can this? please me..i using magento 1.9.0.1 you need have attributes products attributes can used filters have make changes in options.phtml according option name , attribute name matching

rename - How to use a csv file with oldvalue:newvalue to replace string inside files and filenames -

we have large number of rules files carry 1 of >200 phonenumbers in filename and/or reference phonenumber in file itself. of these phonenumbers need changed have input csv file has column old phonenumber , column phonenumber. additional complication, there comments inside files contain phonenumber, spaces in right places, e.g. 0800 123 456. phonenumbers in csv file spaces in comments. what want achieve write (shell) script reads csv file , replaces occurences of old phonenumber inside files (with , without spaces) new phonenumber (again spaces in comments , without spaces in other places). additionally, if file found has phonenumber in filename, should renamed. i'm sure can done sed , similar tools i'm lacking experience sed. i able find solution myself. it's not beautiful , far being efficient job. preconditions input file lines in following format: <old string>;<new string> the "old string" in case phone number in format

multithreading - Iterate on a vector of promise in C++ -

i'm quite new c++ multithreading , i'm trying handle vector of promise when thing @ end of main: (promise<bool> pr : vect){ pr.get_future().get(); } the compiler gives me error. how should iterate in vector? std::promise not copyable, , range-based trying make copies of vector members. need use reference when iterating in way: for (promise<bool>& pr : vect) { ... }

How do I get the number of unique cases used to get the frequency of the other variable using SPSS? -

Image
i have 2 columns, containing person's data on repeated measurements , other 1 presence or absence of characteristic. data reads (column wise); patient_code : 1 1 2 2 2 3 4 5 5 6 6 characteristic: n y y y n n n y y n n i want number of unique cases used frequencies in other variable. ex: y - 5 (from 3 cases/patients) n - 6 (from 5 cases/patients). how do using spss. have several characteristics this. the trick here create unique identifier of patients within each exposed group. sort cases followed match files achieves this, ctables tabulates results. data list list / patid(f1.0) exposed(a1). begin data 1 "n" 1 "y" 2 "y" 2 "y" 2 "n" 3 "n" 4 "n" 5 "y" 5 "y" 6 "n" 6 "n" end data. sort cases exposed patid. match files file=* /by exposed patid /first=primary. ctables /vlabels variables=primary display=none /table exposed[

real world haskell - chapter 23 how to install gtk and glade -

i working way through book real world haskell, far found way adapt code snippets make them run time stuck. i have install gtk , glade bindings in order run gui example in chapter 23. this have done: ~/prog/haskell/realworldhaskell/chapter23 $ cabal sanbox init ~/prog/haskell/realworldhaskell/chapter23 $ cabal install gtk2hs-buildtools ~/prog/haskell/realworldhaskell/chapter23 $ cabal install gtk which worked, when did: ~/prog/haskell/realworldhaskell/chapter23 $ cabal install glade i get: resolving dependencies... notice: installing sandbox located @ /home/fayong/prog/haskell/realworldhaskell/chapter23/.cabal-sandbox configuring utf8-string-0.3.8... building utf8-string-0.3.8... installed utf8-string-0.3.8 configuring cairo-0.12.5.3... configuring glib-0.12.5.4... failed install cairo-0.12.5.3 build log ( /home/fayong/prog/haskell/realworldhaskell/chapter23/.cabal-sandbox/logs/cairo-0.12.5.3.log ): [1 of 2] compiling setupwrapper ( /tmp/cairo-0.12.5.3-13890/cairo-

Why we are unable to decrypt the data in java that is encrypted in python using RSA Encryption using ECB/PKCS1 -

here code encrypting data in python from crypto.cipher import aes crypto.publickey import rsa crypto.hash import sha256 base64 import b64decode import base64 mode = aes.mode_cbc key_bytes="htj9baaamg9xxk6uls4jgg==" # random 128 bit key generated iv_bytes = "secretkey" cipher = aes.new(key_bytes, mode, iv_bytes) def pad(text): bytenum = len(text) packinglength = 8 - bytenum % 8 appendage = chr(packinglength) * packinglength data=text + appendage return data plain_text="some text encrypt" data = pad(plain_text) encrypted_bytes = cipher.encrypt(data) encrypted_string = base64.urlsafe_b64encode(encrypted_bytes) encrytid = open("encryptid.txt",'w') #writting encrypted data ref encrytid.write(encrypted_string) encrytid.close() keys = b64decode('htj9baaamg9xxk6uls4jgg==') key = (open('public.pem', 'rb').read()) #reading public.pem data rsakey = rsa.importkey(key) rsakey = pkcs1_oaep.new(rsakey) encrypt

rounding - Round Off in PHP -

i want round off number exact value of decimal in php. eg: 1.399 => 1.39 or 363.3 => 363.30 i have used printf("%.2f", 1.399) , number_format((float)$a,2,'.','') answer 1.40 incorrect me. you can use floor() round down: $number = 1.399; $roundednumber = number_format(floor($number * 100)/100, 2); echo $roundednumber; //returns 1.39

javascript - If statement checks regardless of the case of the letters -

i want make if statement flexible. if input exact info in input box, statement triggers if user put in lower case or uppercase cannot detected. here codes. var find = _.findwhere($scope.allcast, {name: castname}); if(!find){ var cast = { cpportfolioitemid: id, name: castname, job: 'cast', role: castrole }; contentassessmentfactory.addcastdetail(cast); }else{ $window.alert('cast name exist.'); } any appreciated. you can use _.filter() converting cast.name , castname in lower or upper case. //return array of matched elements var find = _.filter($scope.allcast, function(cast){ //convert both text in lower case , compare //if required can use .trim() castname.trim().tolowercase() strip whitespace return cast.name.tolowercase() == castname.tolowercase(); }); if(f

c# - How do I configue StructureMap to create a DbConnection -

i have code below entity framework context. i using overloaded constructor inject in in memory database testing. works fine when use in mvc app need configure structuremap dbconnection. don't know how this public class efcontext : dbcontext { //this can full blown connection string or if single string defaulting sql express public efcontext() : base("sqlexpresspaxiummusic") { } public efcontext(dbconnection connection) : base(connection, true) { } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { database.setinitializer(new dbcontextinitialiser()); } public dbset<user> users { get; set; } } public static icontainer initialize() { objectfactory.configure(config => { config.scan(scan => { scan.thecallingassembly(); scan.withdefaultconventions(); }); config.for<iwebauth

.htaccess - Multiple apps Codeigniter: remove "index.php/controller" from URL -

i new codeigniter , trying understand basics , maybe advance methods set mvc based application. after while thought might try set admin panel , created , second folder admin application. this folder structure: www.domain.com --frontend --admin in each folder app set it's own .htaccess file. bellow .htaccess file admin side. <ifmodule mod_rewrite.c> rewriteengine on rewritebase /admin/ rewritecond $1 !^(index.php|resources|robots.txt) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l,qsa] </ifmodule> current working url www.domain.com/admin/index.php/admin/posts , trying pointless change w ww.domain.com/admin/posts . how remove /index.php/admin url. the $config['base_url'] set accordingly each side(admin/frontend) , default index.php set null , $config['index_page'] = ''; is problem cause have 2 different apps or bad configuration? best practice multiple app

android - How to make Parse's "done" callback to be called immediately when network is unavailable -

the title says all. i have table on parse server, fill manually, in app want count query this: mcurrentparsequery = parsequery.getquery(favoritetable.name); mcurrentparsequery.setcachepolicy(parsequery.cachepolicy.network_else_cache); mcurrentparsequery.countinbackground(new countcallback() { @override public void done(int count, parseexception e) { } }); as have tested, seems parse listens on event when network become available starts query, when network unavailable (either wifi or data connection) done callback never gets called. my question how make parse call done callback when network unavailable, parseexception.

android - Need Google Drive APIs Client Library code running samples -

we need full access of users google drive, it's providing limited access. unable find google apis client library samples. attached linked provide following information samples. from documentation the google drive android api supports drive.file , drive.appfolder authorization scopes. if application requires additional permissions or features not yet available in drive android api, must use google apis java client. where can find google apis java client documentation , samples? the gdaa api you're referring api build on top of rest api , supports file scope. the rest api supports drive scope allows access folders/files. i can offer simple demo of basic crud functionality rest api here (and parallel version of gdaa api here ). good luck.

scala - How is the "Any" class works with the "this" variable? -

please refer this, https://github.com/scala/scala/blob/v2.12.0-m1/src/library-aux/scala/any.scala the abstract class uses "this" self reference equality test. far understand "this" not special scala. how "this" value handled in "any" ? this special in scala. first of all, according lexical syntax section of language spec, this reserved keyword. see 6.5 , super part of spec precisely defines semantics of this keyword: the expression this can appear in statement part of template or compound type. stands object being defined innermost template or compound type enclosing reference. if compound type, type of this compound type. if template of class or object definition simple name c , type of this same type of c.this . so in case of any class, this reference actual object method of equality called upon.

c# - How to add security header to soap message in WCF, -

i trying add soap security header username token in wcf, sorry have posted trails in previous post, got more method , added here may work. getting exception "cannot call 'writeendelement' while depth '0'." using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.security.cryptography; using system.servicemodel; using system.servicemodel.channels; using system.servicemodel.description; using system.servicemodel.dispatcher; using system.servicemodel.web; using system.text; using system.xml; using microsoft.web.services3.design; using microsoft.web.services3; //using customassertion.servicereference1; namespace test { public class inspectorbehavior : iendpointbehavior { public clientinspector clientinspector { get; set; } public inspectorbehavior(clientinspector clientinspector) { clientinspector = clientinspector; } public void

javascript - dojo xhrPost progress (callback) event listener? -

in dojo api documentation can find callbacks load , error missing callback progress . load: function(data) { dojo.byid("response").innerhtml = "form posted."; }, error: function(error) { dojo.byid("response").innerhtml = "error..."; } the xmlhttprequest api provides possibility, register event listeners progress event: var oreq = new xmlhttprequest(); oreq.addeventlistener("progress", updateprogress, false); oreq.addeventlistener("load", transfercomplete, false); oreq.addeventlistener("error", transferfailed, false); oreq.addeventlistener("abort", transfercanceled, false); oreq.open(); // progress on transfers server client (downloads) function updateprogress (oevent) {...} has dojo mechanism, similar xmlhttprequest api? the new dojo/request module supports progress events. automatically call new dojo/xhr module on browser platforms. don't confuse these api

xml - Layout Memory Leak (Android Studio) -

i've located weird memory leak in 1 of xml layout files in app , don't know how fix it. here layout code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.deliciouslymad.tsukasa.critterbytes.screen.entereddungeonactivity"> <imageview android:id="@+id/background" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparenttop="true" android:background="@drawable/background"/> <button android:id="@+id/next_room"

anyone can help to check my failed jquery ajax jsonp example? -

my example code hosts here: <html> <head> <title>untitled page</title> <script type="text/javascript" src="/jquery.min.js"></script> <script type="text/javascript"> jquery(document).ready(function(){ $.ajax({ type: "get", url: "http://your-ser.com/reports.json", datatype: "jsonp", jsonp: "callback", jsonpcallback: "haha", success: function(json){ alert('------'+json.name); }, error: function(){ alert('fail'); } }); }); </script> </head> <body> </body> </html> the server end json looks like: {"name": "peter","age&qu

javascript - Display first post from query -

from query: var q = keystone.list('post').paginate({ page: req.query.page || 1, perpage: 10, maxpages: 10 }) .where('state', 'published') .sort('-publisheddate') .populate('author categories'); if (locals.data.category) { q.where('categories').in([locals.data.category]); } q.exec(function(err, results) { locals.data.posts = results; next(err); }); i'm trying display latest post in jade template, this: #{locals.data.posts.post[0].title} but empty, can explain how can this? many thanks edit dump mongodb, not sure how else show whats in data: /** posts records **/ db.getcollection("posts").insert({ "__v": numberint(1), "_id": objectid("553245bbdea6b152f4e96a9a"), "author": objectid("552f90c2d877f67c1c70a0ea")

wordpress - how can i add comments to to a custom page -

i trying display comments of post in custom page in wordpress. want display comments including sub-comments. there way display comments of corresponding post?the_comments() shows comments in database. can use get_the_commets($args)? get_comments() trick you. $comments = get_comments(array('post_id'=>your_id)); will return array of comments particular post. you can check get_comments page more options

java - POST Request Parameter Loss -

client code function call() { var value = $('input[name=form]:checked').val(); if (typeof(value)=='undefined') { alert('select 1 record'); return false; } else { $("#bean\\.id").val(value.split("@@")[0]); var id = $("#bean\\.id").val(); $.post("search.do", {'id': id}, function(data){ }); } } <s:hidden name="bean.id" id="bean.id" /> <s:iterator var="form" value="#request.list" status="offset"> <input type="radio" name="form" value="${form.id}@@${form.status}"></input> </s:iterator> server code struts2 config xml <action name="search" class="<action name>" method="search"> <result name="success" type="json"> <param name="include

ios - how to transition scenes with swift in spritekit -

having trouble figuring out need add below code in order switch scenes when node touched. need replace '....' in order have code below run. override func touchesbegan(touches: set<nsobject>, withevent event: uievent) { .... if touchednode.name == "game button" { let transition = sktransition.revealwithdirection(sktransitiondirection.down, duration: 1.0) let scene = file(size: self.scene.size) scene.scalemode = skscenescalemode.aspectfill self.scene.view.presentscene(scene, transition: transition) } } you can use code : override func touchesbegan(touches: set<nsobject>, withevent event: uievent) { /* called when touch begins */ touch in (touches as! set<uitouch>) { let location = touch.locationinnode(self) if self.nodeatpoint(location) == self.playbutton { let reveal = sktransition.fliphorizontalwithduration(0.5) let letsplay = playsc

scala - Slick 3.0.0: How to query one-to-many / many-to-many relations -

basically same question has been asked year ago slick 2.x ( scala slick one-to-many collections ). i'm wondering if there has progression been made release of reactive slick. let's example have 3 tables. library , book , library_to_book library has many books. want list of libraries books. in scala seq[(library, seq[book])] . query have follows: val q = (for { l <- libraries ltb <- librarytobooks if l.id === ltb.libraryid b <- books if ltb.bookid === b.id } yield (l, b) db.run(q.result).map( result => ??? ) results in case of type seq[(library, book)] . how have change query result of type seq[(library, seq[book])] instead? "slick way" of writing such queries? imo code looks fine. depends on feels more readable you. alternatively, can use join well: val findbooksquery = libraries .join(librarytobooks).on(_.id === _.libraryid) .join(books).on(_.id === _._2.bookid) .result val action = (for { booksresult <- fin

algorithm - How to sort command line arguments alphabetically in C++ by pointers -

this code: #include <iostream> using namespace std; int main( int argc, char *argv[]) { int i; // display each command-line argument. for( = 1; < argc; i++ ) cout << " argv[" << << "] " << argv[i] << "\n"; } how can sort ouput alphabetically pointers? #include <iostream> #include <algorithm> using namespace std; bool mycmp(const string& a, const string &b) { return (a<=b); } int main( int argc, char *argv[]) { int i; sort(argv+1, argv + argc, mycmp); for( = 1; < argc; i++ ) cout << " argv[" << << "] " << argv[i] << "\n"; }

Dynamic query using hibernate criteria api -

i want build query dynamically using hibernate criteria api.i facing problem "order by".suppose have statement criteria crit = session.createcriteria(product.class); crit.addorder(order.asc("price")); now want control "asc" or "desc" based on user input.is possible? the criteria object api provides order class main api manage sorting.the order class has 2 methods set sorting order: asc(string attribute) : sorts query attribute in ascending order . desc(string attribute) : sorts query attribute in descending order . now if want control "asc" or "desc" based on user input can following let assume user input can "asc" or "desc". criteria crit = session.createcriteria(product.class); if (userinput.equals("asc")) { crit.addorder(order.asc("price")); } else if (userinput.equals("desc")) { crit.addorder(order.des

ruby on rails - How do I prevent all action specific invocations in nginx -

i want write mapping rule prevent following routing errors in rails app front-ended nginx. should use following rule prevent errors listed below? if ($request_uri ~* "(*.action)" ) { return 444; } production.log-20150419:actioncontroller::routingerror (no route matches [head] "/index!download.action"): production.log-20150419:actioncontroller::routingerror (no route matches [head] "/index!execute.action"): production.log-20150419:actioncontroller::routingerror (no route matches [head] "/index!wcindex.action"): production.log-20150419:actioncontroller::routingerror (no route matches [head] "/index!oaindex.action"): production.log-20150419:actioncontroller::routingerror (no route matches [head] "/userinfoaction.action"): production.log-20150419:actioncontroller::routingerror (no route matches [head] "/admin/install!license.action"): production.log-20150419:acti

javascript - How do I make this drop down list touch friendly -

i wanted make list touch friendly javascript or css. how do it? when searching on google different version of drop down (the 1 @ head of page,and how make touch friendly <select class="form-control" name="dob_month"> <option>january</option> <option>february</option> <option>march</option> <option>april</option> <option>may</option> <option>june</option> <option>july</option> <option>august</option> <option>september</option> <option>october</option> <option>november</option> <option>december</option> </select> <select name="dob_date" class="form-control"> <option value="01">1</option> <option value="02">2</option> <option value="03">3</option> <

How can F# report syntax and semantic errors at same time? -

Image
here f# code both syntax , semantic errors: let b = b b let x = (if) edit: f# vim reports both infinite type error , syntax error, fsc or fsi stops @ sytnax error. how f# vim report syntax , semantic error @ same time, while f# compiler stop @ reporting syntax errors? the f# compiler (which used vim plugin under cover) has error recovery mechanism - means when finds expression cannot parse, attempts fill make valid f# expression. when write let = (if) , guess compiler internally expands like let = (if _ _ else _) _ special "invalid expression" placeholder. this makes possible type-check invalid f# code, useful in ide when writing code (which invalid) because type information used auto-completion etc. reporting type-checking errors in automatically "fixed" code when running compiler directly possible, not useful - when filling in holes, compiler may not expect , give odd error messages.

.htaccess - Jquery post is not working due to htaccess file in Codeigniter -

i placed .htaccess code remove index.php url in amazon server. after placing jquery post function not working me.please me issue.here .htaccess code. <ifmodule mod_rewrite.c> rewriteengine on rewritebase / #removes access system folder users. #additionally allow create system.php controller, #previously not have been possible. #'system' can replaced if have renamed system folder. rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ /index.php?/$1 [l] #when application folder isn't in system folder #this snippet prevents user access application folder #rename 'application' applications folder name. rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ /index.php?/$1 [l] #checks see if user attempting access valid file, #such image or css document, if isn't true sends #request index.php rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewrit

python 2.7 - Can you play sound in windows while doing another task simultaneously? -

is there way while playing winsound.playsound("some sound", flags) change photolabel? i've been trying , no matter put play sound play sound before changing photo label. my code: def thriller(self): winsound.playsound("thriller.wav", winsound.snd_nodefault) img5 = imagetk.photoimage(image.open('thriller.jpg')) self.photolabel.configure(image = img5) self.photolabel.image = img5 self.original_board() def original_board(self): pil import image, imagetk self.image = image.open("board.jpg") self.photo = imagetk.photoimage(self.image) self.photolabel.after(5000, lambda: self.photolabel.configure(image=self.photo)) yes can. have play sound asynchronly. flag winsound.snd_async should work. if not help, can spawn winsound function in new thread (or in python better new process) such played @ same time image changes. good luck!

elasticsearch - How to query for values associated with a key across all documents? -

let's there documents in index this: { "properties":[ { "name":"foo", "value":"2" }, { "name":"boo", "value":"sausage" } ] }, { "properties":[ { "name":"foo", "value":"8" }, { "name":"boo", "value":"chicken" } ] } i'd query index in way return properties.name associated properties.value values. result should contain this: { "foo":["2","8"], "boo":["chicken","sausage"] } how can such result? update: can achieve single query? you can use multi search api : $ cat requests {"index" : "test"} {"fields" : ["value"], "query" : {"term": {"properties.name": "

How to display comments of a particular post in wordpress? -

i'm trying display comments of selected post in wordpress. how can display comments of particular post id? first find out post_id of post want fetch comments from. <?php // comments of post_id 5 $args = array('post_id' => 5); $comments = get_comments( $args ); // loop through comments foreach($comments $comment) : echo($comment->comment_author . '<br />' . $comment->comment_content); endforeach; ?>

c# - Count Sort Algorithm, Unable to sort Perfectally -

i been trying implement count sort algorithm . every time run algorithm gives me wrong answer @ index 0 , 1 it been continuous 20 hours, , unable track doing wrong... generated_array 17 88 14 91 151 50 95 175 92 49 116 67 111 195 37 63 144 50 65 90 sorted_array 0 14 17 37 49 50 50 63 65 67 88 90 91 92 95 111 116 144 151 175 generated_array 8 109 33 37 196 156 158 142 52 179 152 182 171 27 54 75 139 193 25 190 sorted_array 0 8 25 27 33 37 52 54 75 109 139 142 152 156 158 171 179 182 190 193 generated_array 51 24 132 150 73 198 111 55 64 145 15 179 117 6 16 120 155 45 52 108 sorted_array 0 198 15 16 24 45 51 52 55 64 73 108 111 117 120 132 145 150 155 179 generated_array 15 119 162 199 104 104 71 69 40 141 50 119 32 6 155 75 150 140 164 6 sorted_array 0 199 6 15 32 40 50 69 71 75 104 104 119 119 140 141 150 155 162 164 generated_array 22 150 91 145 164 15

c# - Is there any way to copy a text from another program without Select it? -

i want copy text other program, in program ctrl+a considered other command, , can't use " sendkeys.sendwait("^a");" select text. is there way copy text? you can uiacomwrapper , need handle window (from trying copy) , information element can uiautomationverify . var elementcollection = automationelement.fromhandle(windowhandle).findall(treescope.subtree, condition.truecondition); foreach (var item in elementcollection) { //check item properties if element 1 looking } also, instead of condition.truecondition can provide more complex filter 1 element. edit , added real example: [dllimport("user32.dll", setlasterror = true)] public static extern intptr findwindow(string lpclassname, string lpwindowname); const string internetexplorerclass = "ieframe"; static void main() { var windowhandle = new intptr(0); //find internet explorer instance windowhandle = findwindow(internetexplorerclass, null); if (!win

node.js - Redis - How to expire key daily -

i know expireat in redis used specify when key expire. problem though takes absolute unix timestamp. i'm finding hard time thinking should set argument if want key expire @ end of day. this how set key: client.set(key, body); so set expire at: client.expireat(key, ???); any ideas? i'm using nodejs , sailsjs thanks! if want expire 24 hrs later client.expireat(key, parseint((+new date)/1000) + 86400); or if want expire @ end of today, can use .sethours on new date() object time @ end of day, , use that. var todayend = new date().sethours(23, 59, 59, 999); client.expireat(key, parseint(todayend/1000));

appcelerator - Titanium in-app purchase with ti.storekit - product not found -

Image
i have in-app product set purchase in itunes connect via ti.storekit: my appcelerator 4.0 app compiles , deploys device (dev profile). ti.storekit linked app , compiles. seems execute correctly, in terms of no unhandled exceptions. telling me can't find in-app purchase product. have tried handing "15 keys" , "15keys" ti.storekit. wasn't sure 1 wanted (reference name or product id) - anyway neither works. here's documentation i've been following . and here function in ti.storekit produces error message: function requestproduct(identifier, success) { storekit.requestproducts([identifier], function (evt) { if (!evt.success) { alert('error: failed talk apple!'); } else if (evt.invalid) { alert('error: invalid product: ' + identifier); } else { success(evt.products[0]); } }); } the "else if" line being executed: alert('

text - How do I draw 2D fonts in processing P3D mode? -

i'm running sketch array of points in 3d space (p3d). i'd add interface drawing text if "onscreen"/2d, using "x, y" parameters. when tried adding "text("!@#$%", width/2, height/2);" rendered in 3d space. is possible? tried "textmode(screen) doesnt exist in processing 2 anymore. a workaround comes mind create 2d pgraphic has same width/height sketch, give transparent background, draw text want on it, , draw pgraphic onto real sketch if copying on image source data.

Database Handler in Realm for Android -

i trying implement realm in android. there way implement database handler in sqlite ? every samples found in ui , under button clicks. there no pure implementation on seperate database file. i have database handler class below: public class databasehandler extends sqliteopenhelper { private static final int database_version = 1; private static final string database_name = "mytrain"; private static final string table_route = "route"; private static final string column_id = "id"; private static final string column_routename = "routename"; private static final string column_remarks = "remarks"; public databasehandler(context context) { super(context, database_name, null, database_version); } @override public void oncreate(sqlitedatabase db) { string create_route_table = "create table if not exists " + table_route + "("+column_id+" integer primary key," + column_routename+"

java - Acces to a Text Field from another class -

i'm working on mini project , find difficulties. indeed, have class jframe "interfaceconnexion" enter username , password, after having clicked jbutton enter, reach new jframe "interfaceclient". in latter wish informations related "username" (i connected database). thought using "username" , "password" entered user can not because textfield private default, impossible have username , password entered in textfield class. hope clear enough in setting out problem. thank you assuming username , password jtextfields contained within "interfaceconnexion" (incorrect spelling way), should create getter methods less restrictive access modifiers (eg. public or protected) both of the text fields. you may wish consider using jpasswordfield instead, password input.

ios - how to use drawViewHierarchyInRect -

i want create snapshot image uiview, used use renderinrect, slow, , found drawviewhierarchyinrect newer api since ios 7, want try it. i write below code, never create valid image, blank image. -(void)drawrect:(cgrect)rect { uigraphicsbeginimagecontextwithoptions(_mapview.bounds.size, _mapview.opaque, [[uiscreen mainscreen] scale]); cgcontextref context = uigraphicsgetcurrentcontext(); // used use renderincontext, it's slow // [mapview.layer renderincontext:context]; [_mapview drawviewhierarchyinrect:_mapview.bounds afterscreenupdates:yes]; uiimage *image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); self.thumbimageview = [[uiimageview alloc] initwithimage:image]; [self addsubview:self.thumbimageview]; } the -drawviewhierarchyinrect:afterscreenupdates: , lets render snapshot of complete view hierarchy visible onscreen bitmap context. renderincontext: renders directly calayer's render tree va

mysql - PHP-HTML5-Form - My query-generated dropdown posts a blank value -

when load page, value of variable, $v_updateone, "select version". when select version, value goes blank. need grab selected value use in db update statement. thank assistance. -james <form method="post" action="update.php" width="50"> <?php $avquery = "select $v_software1 version_master.vermas_availableversions $v_software1 not null order sortcol desc"; $a_availvers = mysql_query($avquery); #_version dropdown box echo "<select name='availversone' onchange=submit()>"; echo "<option>select version</option>"; while ($row = mysql_fetch_array($a_availvers)) { echo "<option value='" . $row['$v_software1'] . "'>" . $row[$v_software1] . "</option>"; } echo "</select>"; $v_updateone = $_post['availversone']; echo $v_updateone; ?> </form> you have error in valu

python - Decorator to allow function to accept arbitrary arguments -

how can write decorator decorated functions can accept (and ignore) arbitrary arguments? i have functions this: def foo(x): return x def foo2(x, y): if bar(y): return x else: return x + 1 def foo3(x, y, z): ... foo() can calculate return value given x based on x , foo2() needs parameter, , foo3() needs third parameter. have method elsewhere that, among other things, calls either foo() , foo2() , etc depending on user-specified argument. right now, method grabs appropriate function getattr(user_arg) , calls of x , y , z . avoid typeerror wrong number of arguments, foo functions defined *args this: def foo(x, *args): return x but i'd have decorator avoid including *args in every single foo function definition. there way that? or can suggest better way organize code? one way write method this: if user_arg == 'foo': foo(x) elif user_arg == 'foo2': foo2(x, y) elif user_arg == 'foo3': f

batch file - Display one of two messages (randomly, 50-50 chance) -

i creating .bat file generates solar system , make planets in random orders. wondering if there code make possible. if not, ideas use substitute? set /a rand=%random% %% 2 %% "modulo operator". (the rest, when dividing first argument throught second 1 e.g.: 5 modulo 2 = 2*2 rest 1 ) a modulo operator of 2 give 0 or 1 , operator of 4 give 0 , 1 , 2 or 3 note passionate mathematicans: know, operators, not exactly random, game effect negligible (less 0,0001)

javascript - AngularJS RESTful Web Service - Add row to table without refresh -

i'm trying add new row table after save new object. example follow: var demoapp = angular.module("demoapp", ["ngresource"]); // controller demoapp.controller("savecategorycontroller", function($scope, savecategoryservice, categoriesservice){ $scope.categories = categoriesservice.query(); $scope.createcategory = function(){ savecategoryservice.savecategory($scope.category); // want avoid method refresh table. // $scope.categories = categoriesservice.query(); }; }); // factory demoapp.factory("savecategoryservice", function($resource){ return $resource("/demopro/savecategory", {}, { savecategory: { method: "post" } }); }); demoapp.factory("categoriesservice", function($resource){ return $resource("/demopro/categories", {}, { listallcategories : { method: "get", isarray: true

python - Turning a list or user generated strings into a single string -

i'm getting input users list of strings, ie: ['a','b','c','d'] the strings "hat" short essay. need store list in database string, , pull string out , turn list later. advice on safest / fastest way this? far i've considered: csv json using longish delimiter string ( &break; ) my preference, far, msgpack (and xml). has canonical interface protocol.dumps / protocol.loads similar json , support python base types similar json , other packing libs. json readable both human , programs, lot of tools e.g. jsonselect or postgresql. pickle handy complex python types/classes #lazy msgpack performant speed & space wise. can swap json , it's not "bloated". works great utf-8. csv ok lists , tables. it's more compact json , easy parse when it's under control #security. can save some cpu cyles & bandwidth . doesn't support nested lists default. xml portable, verbose, vali

java - OJDBC connection with NetBeans -

Image
i'm trying establish new connection oracle database ojdbc7 driver , when "customize connection" step, following message: cannot establish connection jdbc:oracle:thin:@localhost:1521:xe using oracle.jdbc.oracledriver (ora-01017: invalid username/password; logon denied ) can explain do? tried putting in different formats of username , password, tried stopping , starting database again (express edition 11g), couldn't find on web... oracle has detailed tutorial on how setup connection netbeans oracle express edition https://netbeans.org/kb/docs/ide/oracle-db.html you can connect using existing users, if want create new user need directly in database regardingthe jdbc url sintax here example jdbc:oracle:thin:@//localhost:1521/xe, username = sys , password = 123456

r - object no found error in testthat tests -

here code: setgeneric("iflet", function(sym, x, body1, body2, ...) { standardgeneric("iflet") }) #' @name iflet #' @export setmethod("iflet", signature(sym = "name", x = "any", body1 = "any", body2 = "any"), function(sym, x, body1, body2 = {}) { e = new.env() sym_str = deparse(substitute(sym)) iflet(sym_str, x, body1, body2) }) #' @rdname iflet #' @export setmethod("iflet", signature(sym = "character", x = "any", body1 = "any", body2 = "any"), function(sym, x, body1, body2 = {}) { stopifnot(length(sym) == 1) e = new.env() e[[sym]] = x if(e[[sym]]) { eval(substitute(body1), e) } else { eval(substitute(body2), e) } }) # test iflet(

java - Smack throws "NoClassDefFoundError: Failed resolution of: Lorg/jxmpp/util/XmppStringUtils" -

i got problem app in want create simple xmpp client connects server. got following problem when i'm starting app (compilation runs through without problems), app closes instantly. java.lang.noclassdeffounderror: failed resolution of: lorg/jxmpp/util/xmppstringutils; @ org.jivesoftware.smack.provider.providermanager.getkey(providermanager.java:314) @ org.jivesoftware.smack.provider.providermanager.addstreamfeatureprovider(providermanager.java:304) @ org.jivesoftware.smack.provider.providermanager.addloader(providermanager.java:140) @ org.jivesoftware.smack.initializer.urlinitializer.initialize(urlinitializer.java:54) @ org.jivesoftware.smack.smackinitialization.loadsmackclass(smackinitialization.java:232) @ org.jivesoftware.smack.smackinitialization.parseclassestoload(smackinitialization.java:193) @ org.jivesoftware.smack.smackinitialization.processconfigfile(smackinitialization.java:163) @ org.jivesoftware.sma