Posts

Showing posts from January, 2015

Why can't I push onto stack? Java 6 generics -

i have no idea why i'm unable simple push generic type of object onto stack. i've decided need figuring out. have: private void preordertrav(bstnode<k> node) { if(node != null){ mystack.push(node); //null pointer exception while(!mystack.isempty()){ mystack.pop(); node = node.getleft(); mystack.push(node.getright()); mystack.push(node.getleft()); } } } this being called constructor: public bstsortedlistiterator(bstnode<k> root) { preordertrav(root); } anyone have ideas? error, way: exception in thread "main" java.lang.nullpointerexception @ bstsortedlistiterator.preordertrav(bstsortedlistiterator.java:33) @ bstsortedlistiterator.preordertrav(bstsortedlistiterator.java:31) @ bstsortedlistiterator.<init>(bstsortedlistiterator.java:43) @ bstsortedlist.iterator(bstsortedlist.ja

cordova - How to implement push notification in app being developed for Black Berry OS 6.0 using Phonegap and html5 framework like Sencha Touch -

it stated in black berry developer website html5 notification supported in black berry 10 only. there way implement push notification in app being developed black berry os 6.0 using phonegap , html5 framework sencha touch. any suggestions, workout examples appreciated. you can have @ : https://github.com/shaders/phonegap-cordova-push-notifications . or : http://www.pushwoosh.com/programming-push-notification/blackberry-html5-webworks-push-notification-sdk/

shell - Exporting .obj-model to three.js json-object causes python-errors -

i trie export 3d-model use in three.js script. unfortunately not familiar python , 3d stuff much. when run converter-script (convert_obj_three.py) windows shell error. (the script , model in same directory.) $ c:/python33/python convert_obj_three.py -i couch.obj -o couch.js file "convert_obj_three.py", line 781 print "warning: skipping morph [%s] different number of vertices [%d] original model [%d]" % (name, n_morph_vertices, n_vertices) ^ syntaxerror: invalid syntax is because there problem model or make mistake? the problem use python 3 instead of python 2 run script. python 2: print '' python 3: print function , no keyword needs brackets: print('')

c# - How to create onclick event in .cs file for html <Input> Tag? -

how create onclick event in .cs file asp.net c# html tag ? example :- < input type="button" id="btnbeforeok" value="ok" name="btnbeforeok" style="width: 90%;" /> i want create event in .cs file how can ? or bool isemail = regex.ismatch("nikunj@yahoo.com", @"\a(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2}|asia|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel)\b)\z", regexoptions.ignorecase); the above bool isemail want in .aspx page ? very simple. html: <input type="button" id="btnbeforeok" value="ok" runat="server" name="btnbeforeok" style="width: 90%;" /> now go html view of page , double click on button, generate event , button markup changed below: <input type="button" id="btnbeforeok&quo

php - How to correctly echo database results from checkbox form with submit button into table? -

hello i'm new php, mysql, , html , project i'm working on have simple database id, product, price, , condition. on html form have 4 checkboxes ranges of prices 0-25, 25-50, 50-75, , 75-100. here's example of i'm trying do: if user selects checkbox 0-25, it's supposed echo id, product, price, , condition of products cost 0-25 in table.i have checkbox values saved in array, i'm lost @ point. how can output values in database of checkbox checked. p.s. i've heard of pdo, have use mysql project. here's html: <form action="pricefilter.php" method="post"> <br><b>filter price:</b><br><br> <input type="checkbox" name="pricefilter[]" id="price" value="025"/>&nbsp;$0-$25<br><br> <input type="checkbox" name="pricefilter[]" id="price" value="2550"/>&nbsp;$25-$50<br><br> <input

post - How can I forward PayPal IPN to another PHP file? -

we updating our system , old ipns need processed differently. however, cannot change original ipn send-to addresses. have "bounce" ipn message off of old_ipnprocessor.php , forward new_ipnprocessor.php. cannot modify old_ipnprocessor.php technical reasons go beyond scope of question. from have read, have use curl accomplish this. have seen code this, unsure how it's implemented. instance, $post var in code below (from https://stackoverflow.com/a/6213693/1390395 ) raw json straight paypal. have in php array work? function forwardipn($post){ $url = "new_ipnprocessor.php"; // $post ipn message paypal $content = $post; $curl = curl_init($url); curl_setopt($curl, curlopt_header, false); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_httpheader, array("content-type: application/json")); curl_setopt($curl, curlopt_post, true); curl_s

How to start application(path with space) using QProcess on mac OSX? -

it goes when using qprocess start program if path without space. eg: qprocess app; app.startdetached("open /users/test/desktop/mytest/hello.app"); but, doesn't work if program path containing spaces. eg: qprocess app; app.startdetached("open /users/test/desktop/my test/hello.app"); someone can me , tell me how start program space in path? thanks! you need use quotes in string path:- app.startdetached("open \"/users/test/desktop/my test/hello.app\""); without quotes, space suggest next part of path 2nd parameter passed call open.

jquery - Sort a table with rowspan -

i'm french so, please, don't afraid sentences mistakes. i'm trying sort tab contains cells rowspan : but datatables or tablesorter, don't know if possible. know how can tablesorter ou datatables? know other plugin can ? thanks. you can use plugin: 1. http://tinysort.sjeiti.com/

Error on configuring Ruby Installation -

i've been digging through stackoverflow answer, after 3 days of failure gave installing ruby. currently have installed: ruby (stock) rvm the ruby installer http://railsinstaller.org/ i getting error during configuration. tried switching smf homebrew no good. here error getting: error running 'env ldflags=-l/opt/sm/pkg/active/lib cflags=-i/opt/sm/pkg/active/include cpath=/opt/sm/pkg/active/include ./configure --prefix=/users/unwired/.rvm/rubies/ruby-1.9.3-p392 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libxml2:/usr/local/opt/libxslt:/usr/local/opt/libksba:/usr/local/opt/openssl:/usr/local/opt/sqlite --disable-install-doc --without-tcl --without-tk --enable-shared', please read /users/unwired/.rvm/log/ruby-1.9.3-p392/1366883126_configure.log there has been error while running configure. halting installation. i excited start learning ror installing pain. follow these steps: download rails installer http://rubyin

android - Action Bar with Login Page- already created tabs are shown -

i have created application using actionbar. have used login page in have getting username , password user , have created actionbar tabs. in application have hided action bar before loading login page, after loading login page have shown action bar. till working fine. after logoff login page shown. in time have hided action bar. if login second time, created tabs showing newly created tabs. if created 4 tabs means in second time of login 8 tabs shown. then when re-login have check if there tabs existing don't want have. try implement like: if (tabcount > 0) { //remove tabs } //build tabs

how to get data between td tags in unix shell script -

i want data between td tags in unix shell script in generalize way. for example in following <td style="padding:3px;" align="center">123.456</td> how retrieve 123.456 in generalize way. thanks you can try sed, sat:~# cat file <td style="padding:3px;" align="center">123.456</td> <td>sat</td> sat:~# sat:~# sed 's/<td\(.*[^<>]\+\?>\)\(.*\)<\/td>/\2/g' file 123.456 sat sat:~# i hope you.

android - Calling startActivityforResult from tab activity then Alertdialog will not show in Tabactivity -

i have 3 tabs . 3 activities open tabs . in that, 1 tab contains 2 buttons , 1 opening map in next activity , 1 showing dialog. before clicking on 1st button 2nd button working once click on 1st(map button - fragment activity) 2nd button not working. i opening map tharough startactivityforresult() , return me latitude , longitude . clicking alert button alert not display application hangs time. as per sense dialog displaying not showing. don't know happened. if has idea please me. this functionality working in ics .

wix3.7 - Uunable to see WIX project type in Visual studio 2008/2010 -

i have visual studio 2008, 2010, , wix37.msi (wix 3.7) installed on machine. however, unable see wix project type in visual studio 2008/2010. do need install additional tool/plugin? i have visual studio 2008 , visual studio 2010 installed on machine , installed wix v3.7 rtm codeplex . things work okay me. there known issue in vs2008 requires set msbuild property called runwixtoolsoutofproc true . occurred because parts of wix v3.7 incorrectly built against netfx4.0 , vs2008 runs on netfx2.0.

PayPal Item Name/Description on separate lines using forms -

i processing simple form paypal's express checkout using basic standard free account , standard form "_xclick" option. when passing through item name or description, understand limited 144 characters want have information inside title or description on different lines separate information when on paypals checkout area user can see paying for. i have tried use "\r" , "\n" seperate lines, seen below in "item_name" input using "this line 1\r\nthis line 2\r\nthis line 3" , ignores "\r" , "\n" when passed through paypal payment page , when sent in receipt email. current example code: <form name="theform" method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="currency_code" value="gbp"> <input ty

java - Type Information within serialized JSON using GSON -

using jackson have option attach type info serialized object ( http://jackson.codehaus.org/1.5.5/javadoc/org/codehaus/jackson/annotate/jsontypeinfo.html ). is there way using gson like: { propertyname:"test", _classname:"foo.bar.testclass" } the idea have generic, when arraylist<object> deserialized, right object instances restored it. i saw question: https://stackoverflow.com/a/8683689/1001027 more or less need works specific class of objects. how implement in such generic way, every object serialized property? you need implement deserializer, @ type property , cast objects given type. believe, there no other way. check out javadoc , implementing interface may answer.

axapta - Best/Easier way to add a shape/image to a Dynamics AX 2009 form? -

Image
i add few coloured square shapes form in order display legend. since haven't come across way of adding coloured-in shapes, i've resorted creating shapes images, loading them resources , trying load them form...although seems lengthy workaround simple single-coloured square. first off, there way of adding basic shape of given colour ax form? otherwise, there easier way of adding image form without having replicate companyimage (or companyinfo) form? note: i'm looking have image stored within ax proper , not having image linked filepath image on local machine. you can draw simple shapes wingdi class . here simple sample : void drawshapes() { wingdi wingdi; int brush, height, width; ; //mywindow being formwindowcontrol height = mywindow.heightvalue()/2; width = mywindow.widthvalue()/2; mywindow.lockdc(); wingdi = new wingdi(mywindow.hdc()); brush = wingdi.createsolidbrush(winapi::rgb2int(0, 0, 255)); wingdi.fillr

php - htaccess mod_rewrite, one syntax works, but other no -

when write in .htaccess mod_rewrite rewriteengine on rewriterule ^(.*)\.my_extension$ $1.php this wroks fine. but when trying mod_rewrite this: rewriteengine on rewriterule ^(.*)$ index.php?url=$1 this gives me internal server error when open address, example site.com/somepage so, may reason of this? rewriteengine on rewritecond %{request_uri} !(index.php) rewriterule ^(.*)$ index.php?url=$1 you have redirect loop, need exclude index.php rules.

python - Updating h5py Datasets -

does 1 have idea updating hdf5 datasets h5py? assuming create dataset like: import h5py import numpy f = h5py.file('myfile.hdf5') dset = f.create_dataset('mydataset', data=numpy.ones((2,2),"=i4")) new_dset_value=numpy.zeros((3,3),"=i4") is possible extend dset 3x3 numpy array? you need create dataset "extendable" property. it's not possible change after initial creation of dataset. this, you need use "maxshape" keyword . value of none in maxshape tuple means that dimension can of unlimited size. so, if f hdf5 file: dset = f.create_dataset('mydataset', (2,2), maxshape=(none,3)) creates dataset of size (2,2), may extended indefinitely along first dimension , 3 along second. now, can extend dataset resize : dset.resize((3,3)) dset[:,:] = np.zeros((3,3),"=i4") the first dimension can increased as like: dset.resize((10,3))

.net - Localization to a different alphabet -

so, have finished application written in c# full support localization. far have done translations different languages using latin alphabet. now, need translate app russian cyrillic. can give me quick rundown on needs done conversion?

visual studio 2012 - CleanWPPAllFilesInSingleFolder error makes my project no longer load -

using vs2012 created dynamic data project. worked , started configuring web deployment settings. not sure setting changed there no error. when try , load solution following error project , no longer load. specified condition "$(cleanwppallfilesinsinglefolder)" evaluates "" instead of boolean. c:\program files (x86)\msbuild\microsoft\visualstudio\v11.0\web\microsoft.web.publishing.targets i cannot see cleanwppallfilesinsinglefolder in csproj file. ideas on how fix can load project once more? i had issue well. try following: close visual studio delete .user , .suo files re-open solution. this worked me.

javascript - random css animation on hover -

i have javascript when hover plays animation, have 4 different animations , randomize each time element hovered over here's code function firsthelp() { document.getelementbyid('help-text').innerhtml = 'enter first name'; document.getelementbyid('help-box').style.animation ='greenhover 2s;'; document.getelementbyid('help-box').style.webkitanimation ='greenhover 2s'; } the other css animations bluehover orangehover , purplehover function getrandomanimation(duration) { var possibleanimations = ["greenhover","bluehover","orangehover","purplehover"]; var randomnumber = math.floor((math.random()*4)); return (possibleanimations[randomnumber] + " " + duration || ""); } and use this: document.getelementbyid('help-box').style.animation = getrandomanimation('2s)';

ASP.NET 4 JSON DataContractJsonSerializer Lower Case -

i have class several properties defined in sentence case: public class provider public property providername string end class i need able pass instances of through ajax using in javascript add array, process etc. using datacontractjsonserializer serialize json , return through ashx handler. may me being picky, don't having sentence case properties in javascript, prefer them lower case, produce following: alert(myprovider.providername); with default datacontractjsonserializer cannot find way this! json.net appear simple task, unfortunately can't introduce dependency project - as to. does know of way override format of keys generated? the project using asp.net web forms 4.0. thanks, chris.

soap - call SAOP request in ADF mobile -

i want call soap request using adf mobile. request : <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><soap:header><wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" soap:mustunderstand="1"><wsse:usernametoken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:username>india</wsse:username><wsse:password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext&quo

iphone - Navigation from AppDelegate to a view controller don't disable the audio playing of previous view controller -

i newbie in ios programming. having problem navigation controller. rootviewcontroller 'welcomeviewcontroller'. navigate 'abcviewcontroller' root view & when 'abcviewcontroller' loaded plays audio file. when receive special message 'appdelegate' class, pushing xyzviewcontroller appdelegate class. problem audio playing of abcviewcontroller continues playing though current view showing xyzviewcontroller. player shouldn't play while visible controller xyzviewcontroller. think there problem navigation. how can solve problem? as stated robert, need stop audio in abcviewcontroller viewwilldisapper: hope help.

php - I am trying to post <div> content to database using jquery $.post() -

i want add data table using jquery $.post() method..but not updating. html:this html code <div id="ant-container" name="text" style="border:1px solid #cccccc;height:300px;width:80%;"> <?php if (isset($_post['submit'])&& $_post['text'] ==''){ echo parseword($myfile); }elseif (isset($_post['text'])) { echo $_post['text'];} </div> jquery:this jquery code var div_contents = $('#ant-container').html(); var ides = $('#id').val(); $.post("content.php", { contents:div_contents, id :ides}); in getting both "ides" "div_contents" php:this php code(content.php) $div = mysql_real_escape_string($_post['contents']); $id = mysql_real_escape_string($_post['id']); $sql ="update `antr_essay` set `annotext`= {$div},`grade`='$_post[grade]',`comments`='$_post[comments]' id=$id";

php forms: value="<?php=$_POST['total_amount']?> vs. value="<?=$_POST['total_amount']?> -

my form generating error when use: <input type="hidden" name="total_amount" value="<?php=$_post['total_amount']?>" /> however works fine when use: <input type="hidden" name="total_amount" value="<?=$_post['total_amount']?>" /> i thought insecure use <?= instead of <?php . here complete form: <form name="save_file" action="cyprus_funds_transfer.php" method="post" enctype="multipart/form-data"> <? if($_post['value_type'] == 1) {?> <input type="hidden" name="amount" value="<?php=$_post['account_number']?>" /> <input type="hidden" name="value_type" value="1" /> <input type="hidden" name="total_amount" value="<?php=$_post['total_amount']?>" /> <? } else { ?> &

Does Rails provide default session time-out duration? If yes, where is it specified? -

i know how set expiry time duration in rails app, has been documented on web. want know default time duration session expiry in rails , if there one, find it? rails doesn't have default expiration time. the method definition session_store seems have 1 default: on line 32 @session_store = :cookie_store by default other configurations non existent. therefore, :expire_after not set , rails' sessions don't have expiration time unless set value it.

java - Managed beans and caching view lookups -

from traditional notes development learned retrieving domino objects databases , views in script not effective, , should avoided in loops. in xpages cannot serialize domino objects , retrieve same object many times. have example retrieving project data, based on project number stored in project related documents. bean scoped applicationscope , results cached. public class projects{ private treemap<string, project> projectlist; public projects() { } public project getprojectinfo(string projnum) { project project = null; if (projectlist==null) { projectlist = new treemap<string,project>(); } if (projectlist.containskey(projnum)) { project = projectlist.get(projnum); } else { try { database projdb = dominoaccess.getdatabase("projects");

javascript - jqMobi dynamically update element with ajax data -

using jqmobi 1.2 i'm trying update content of panel result of ajax call. following panel collect string search for. <div id="register_form" class="panel" data-defer="" data-header="default" data-footer="register_footer" data-load="" data-unload=""> <form id="register_data" class="selected"> <fieldset class="scrollable" data-pull-scroller="true"> <legend class="toggelable" >organization:</legend> <div id=""class="toggelable"> <label for="seleced_org" >bezeichnung:</label><br> <input type="text" id="seleced_org" class="toggelable jq-ui-forms" ><br> <a class="button icon magnifier" href="javascript:searchorg();">search</a> </di

.htaccess - how to Protect Php file with the htaccess to protevent external use or a direct use -

if exemple try use php script or external use or direct use want deny him. have tried in htaccess : rewritecond %{http_referer} !^$ rewritecond %{http_referer} !^http://(www\.)?mydomain.com(/)?.*$ [nc] rewriterule \.(php)$ / [nc,r,l] but doesn't seem working, want allow php script when call in page on server. deny/allow way not perfect because it's possible content of php script curl . you try this: rewritecond %{remote_addr} !^127\.0\.0\.1$ rewriterule \.(php)$ / [nc,r,l] or without mod_rewrite: order deny,allow deny allow 127.0.0.1

c# - Exception when trying to connect to SQL Azure Database -

i new windows azure. i have local db .net application. have created azure account along relevant sql azure database. i working on adding c# code in order pass data local application cloud. in order test functionality have added random user want insert azure db. i have used following tutorial: http://www.windowsazure.com/en-us/develop/net/how-to-guides/sql-database/ i trying connect azure sql database using connection string in app.config: <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionstrings> <add name="starentities" connectionstring ="server=tcp:fkr95b1any.database.windows.net,1433;database=starsoftwaredb;user id=starsoft1@fkr95b1any;password=xxxxxx;trusted_connection=false;encrypt=true;" /> </connectionstrings> </configuration> this method being used registration, code establishes connection azure database, failing on 'conn.open();'. sqlconnectionst

security - HTTPS downloads/uploads -

my website accessible through https, provides secure connection user has fill in sensible details. does security extend downloads , uploads done through website? example. provide simple "browse" button upload file, or link download file hosted on website, download/upload secure well? thanks let me explain things first. ssl layer or connection., whichever data being sent/received website in packets , encrypted, whilst prevents "man-in-the-middle attack".[good news..right ? :-)] but .. per request no ssl not ensure security when regards uploads/downloads. you need add exception file types [mime] letting other (end-users) upload server [here, ssl has no work here]. you have set these limitations on coding part ., if these things not handled properly, hacker may upload shell script on upload section , can gain root access server , can't blame on ssl.

ios cocoa: How to adjust the size of the popover depending on the number of rows in uitableview -

Image
this related question ios filter options similar apple store (dropdown list) i tried using uitableviewcontroller instead of pickerview couldn't understand how use picker view if need popping out (any info on appreciated). now did. i have vc calls out "filtervc". have 1 filtervc called 3 different "filter buttons", , populate vc depending on button. issue is, 1 button might have 2 items needed shown, 1 might containg 50. wondering how adjust height of popovercontroller contains uitableview? also, right way in dealing popovers, 3 segues connected 1 vc??? (it needed anchor point) here's looks like as follow question: right way on ipad? feel people prefer uipicker. guy answered first question said it's more of design thing. since i'm no designer, user, think uitableview more appealing? thanks time!! in view you're showing in popover, set self.contentsizeforviewinpopover know size , before view displayed. the main ben

python - How to use user input to end a program? -

i'm new python , writing program converts millimeters inches. continuous loop allows keep putting in numbers , correct converted measurement. want put if statement allow user type "end" end program instead of converting more units of measurement. how go making work (what python code allows exit written program , can used in if statement.)? convert=float(25.4) while true: print("*******mm*******") mm=float(input()) results=float(mm/convert) print("*****inches*****") print("%.3f" % results) print("%.4f" % results) print("%.5f" % results) to end loop, can use break statement. can used inside if statement, since break looks @ loops, not conditionals. so: if user_input == "end": break notice how used user_input , not mm ? that's because code has minor problem right now: you're calling float() before ever check user typed. means if type "end", you&

How to join two result sets in MySQL? -

i want join 2 different result sets in mysql displayed side by. example lets have result set #1 follow - name phone abc 123 def 456 ghi 789 result set # 2 - mail id website jkl@jkl.com www.jkl.com mno@mno.com www.mno.com pqr@pqr.com www.pqr.com now want these 2 result displayed side side in single result set without relation. name phone mail id website abc 123 jkl@jkl.com www.jkl.com def 456 mno@mno.com www.mno.com ghi 789 pqr@pqr.com www.pqr.com how should it? you need join between 2 tables don't have id. well, can't this. tables in sql not ordered, need keys link them. you can something. and, if lucky, work. following adds row number each table , joins on that: select t1.name, t1.phone, t2.mail, t2.website (select t1.*, @r1 r1, @r1 := @r1 + 1 t1 cross join (select @r1 := 0) ) r1 join (select t2.*, @r2 r2, @r1 := @r2 + 1 t2 cross join (select @

android - update Main UI Thread or AsyncTask never allowed than where can i update UI thread? -

this question has answer here: how fix android.os.networkonmainthreadexception? 44 answers caused by: android.os.networkonmainthreadexception 04-25 13:15:52.362: e/androidruntime(20900): @ android.os.strictmode$androidblockguardpolicy.onnetwork(strictmode.java:1117) 04-25 13:15:52.362: e/androidruntime(20900): @ libcore.io.blockguardos.connect(blockguardos.java:84) 04-25 13:15:52.362: e/androidruntime(20900): @ libcore.io.iobridge.connecterrno(iobridge.java:127) 04-25 13:15:52.362: e/androidruntime(20900): @ libcore.io.iobridge.connect(iobridge.java:112) 04-25 13:15:52.362: e/androidruntime(20900): @ java.net.plainsocketimpl.connect(plainsocketimpl.java:192) 04-25 13:15:52.362: e/androidruntime(20900): @ java.net.plainsocketimpl.connect(plainsocketimpl.java:459) 04-25 13:15:52.362: e/androidruntime(20900): @ java.net.socke

c++ - Passing r-value as non-const reference (VS warning C4239) -

what wish (using c++ lambda) effectively: std::vector<mytype> getthearray () {return something;} const auto dosomething = [](std::vector<mytype> & array) { //some processing involves either sorting 'array' or setting temporary flags on items }; dosomething (getthearray ()); this appears disallowed in standard c++ because rvalue cannot passed non-const reference. my questions: 1) there way using type-cast or obliged create temporary variable store results of getthearray ()? 2) there reason why disallowed in c++? please note 'something' returned 'getthearray' array constructed on fly, not stored value. it seems comments want take vector, modify destructively (in sense original state cannot reset) , use result internally. , want work efficiently both lvalues , rvalues. the next question whether in case of lvalue, code holds original container needs after function call has completed, , if needs original state of vect

function - Upside-down Gaussian distribution -

i'm looking function upside-down function of gaussian. when x = 0, y should 0. on both sides (positive , negative) function should converge 1. can point me in right direction? if want function, subtract gaussian distribution function 1. won't probability distribution function that, of course; such function must satisfy $\int_{-\infty}^{\infty} f(x)\,dx = 1$ . (this wrong stack exchange site typing mathematics in tex.) function want won't integrable.

multithreading - c# events execution are thread safe? -

i read lot of event , threads discussion, of focus in "what happen" if unsuscribe event , try call later. question different...what happen if have process in thread fires event "i finish" in millisecond 1, , have process in thread b fires event "i finish" in millisecond 2. both processes suscribed same method listen , handle event. so, c# has execute method handles event 2 times: 1 time event fired in thread a, , 1 time event fired thread b. what happen?? c# locks method when "first event coming thread a" starts execution of method handles event, , unlock method when finish execution, allowing other waiting "events" execute method content?? or event fired thread start execution of method handles event, , 1 millisecond later event fired thread b start execution on same method wihtout notice method being executed other "process"??? im asking this, because want file writing in method catch event, if method can execute

java - References to generic type SparseArray<E> should be parameterized -

i tried googling warning , seem find others seems bit off. type safety: method put(int, object) belongs raw type sparsearray. references generic type sparsearray should parameterized can explain me warning? sparsearray works java generics . ideally, should declaring sparsearray<whateveryourvalueclassis> , storing instances of whateveryourvalueclassis via put() .

c# - Nullable problems with Activator.CreateInstance and Convert.ChangeType -

i have third party library sets given objects property using reflection follows. (this simplified version) public void set(object obj, string prop, object value) { var propinf = obj.gettype().getproperty(prop); value = convert.changetype(value, propinf.propertytype); propinf.setvalue(obj, value, null); } and have class nullable property class test { public int? x { get; set; } } when write following code, says cannot convert int int? var t = new test(); set(t, "x", 1); since nullable not implement iconvertible makes sense. decided write method returns nullable version of given value typed object. public object makenullable(object obj) { if(obj == null || !obj.gettype().isvaluetype) throw new exception("obj must value type!"); return activator.createinstance( typeof(nullable<>).makegenerictype(obj.gettype()), new[] { obj }); } i hoped use method follows. var t = new test(); set(t, "x&

iphone - How to get saved image file path in iOS -

hi developing app in there option pick photos ios photo gallery. have upload selected photos server. upload images using kaltura sdk in situation not able directly send uiimage server. need send saved image file path . for found solution, saving selected photos in particular file path use file path. problem not wish save photos again in phone memory because photos stored in particular path. so there other option retrive saved image file path without saving again? try one: - (void)saveimage: (uiimage*)image { if (image != nil) { nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring* path = [documentsdirectory stringbyappendingpathcomponent: @"test.png" ]; nsdata* data = uiimagepngrepresentation(image); [data writetofile:path

Scala View + Stream combo causing OutOfMemory Error. How do I replace it with a View? -

i looking @ solving simple problem, eratosthenes sieve, using idiomatic scala, learning purposes. i've learned stream caches, not performant when determining nth element because it's o(n) complexity access memoisation of data, therefore not suitable situation. def primes(nums: stream[int]): stream[int] = { stream.cons(nums.head, primes((nums tail) filter (x => x % nums.head != 0))) } def ints(n: int): stream[int] = { stream.cons(n, ints(n + 1)) }; def nthprime(n: int): int = { val prim = primes(ints(2)).view take n tolist; return prim(n - 1); }; the integer stream problematic one. while prime number filtering done, jvm runs outofmemory. correct way achieve same functionality without using streams? basically take view of primes view of ints , display last element, without memoisation? i have had similar cases stream idea, did not need store it's values. in order consume stream witho

c# - Progress Bar not Visible -

if create progressbar via toolbox , add following line in code: progressbar1.value = 40; i able view progress bar when application runs. however, if try create 1 via code, unable view 1 - progress bar not visible. here code: progressbar progressbar1 = new progressbar(); progressbar1.location = new system.drawing.point(168, 180); progressbar1.height = 650; progressbar1.width = 340; progressbar1.minimum = 20; progressbar1.maximum = 100; progressbar1.value = 49; progressbar1.visible = true; if using windows forms must add form that: this.controls.add(progressbar1); if using wpf must that: this.children.add(progressbar1);

Expand/Collapse in android-amazing-listview -

i using http://code.google.com/p/android-amazing-listview/ displaying sectioned listview. can point me tutorial or links on how can expand/collapse using library. it doesn't support feature.

javascript - Canvas collision? -

testing game , when user , monster collide want alert pop no luck: function die() { (var = 0; < monster.length; i++) { if (user.destinationx === monster[i].destinationx && user.destinationy === monster[i].destinationy { alert("die"); } } } i'm going provide merged answer explanation. if explanation, credit either karaxuna or user2317489 . your problem is, kolink mentioned, pacman glitch, or rather, fact monsters not pixels - have size of own. checking origin of 1 object , seeing if equal entity's - rarely, if ever, case. instead, need check if monsters have @ least 1 common point (in other words, collision checking). this can trivially done checking if origin of 1 inside bounding box of other, or in other words, if monster2.x <= monster1.x <= (monster2.x+monster2.width) , monster2.y <= monster1.y <= (monster2.y+monster2.height) . code arnelle balane has provided without explanation that. this not approx

python - Only the first digit of my data gets put in an array -

import numpy np import asciidata def leesdata(): ra = [] dec = [] data = asciidata.open('s0-2.txt') in data[1]: ra.append(float(i)) in data[2]: dec.append(float(i)) return ra, dec ra, dec = leesdata() print ra, dec when run this: [-0.04] [0.15, 0.138, 0.124, 0.098, 0.088, 0.078, 0.05, 0.041, 0.02, 0.01, -0.017, -0.004, 0.011, 0.072, 0.079, 0.085] so first number of data gets put in array ra, dec works fine. doing wrong? here file i'm trying open http://home.strw.leidenuniv.nl/~snellen/ps/s2_pos.dat normally i'd use combination of open , read this. here's how i'd read in file: f = open('s0-2.txt', 'r+') ra = [] dec=[] line in f: if ( not(line.startswith('#')) ): ra.append( line.split()[1] ) dec.append( line.split()[2]) print ra print dec

c# - Using "<input type="file" .... />" instead of asp:FileUpload -

i'm modifying existing asp.net project. original author erroneously tried create styled asp:fileupload setting visibility hidden , creating 2 custom styled browse , save buttons. for security reason, ie not permit this. strategy instead try use input tags type="file", this example . if set input <input type="file" id="inputfile" /> how access/save file in code behind, inputfile.saveas("somefile.txt"); ? (in code behind) can inputfile.hasfile or there other analog of this? as per recommendations i'm trying following: <td> enabled: <asp:checkbox id="checkbox2" runat="server" /> &nbsp;&nbsp; <div id="testfileuploader">> <input type="file" id="browserhidden" runat="server" /> <div id="browservisible"><input type="text&

Invoke Spotify ad in premium version -

for testing app (spotify apps api) free version of spotify need invoke commercial track. in following document says can use uri spotify:ad:9ca1a889f34945d59fc521759dd177a7 invoke commercial program: http://d2mua6lfj9ozyq.cloudfront.net/old/pdf/partner-checklist.pdf remember used work in past, when type in search bar now, there nothing happening, nor there error message. can invoke commercial? try alternative ad uri, spotify:ad:5e8c1e01cc7d4e16a0c273ecd93d2742

r - How to make scale_x_date week start with Sunday -

i'm creating weekly time series chart, , week should start sunday. when specify scale_x_date(breaks = date_breaks('1 week')) grid line , labels start on monday, results looks off. how can force ggplot scale_x_date week start on sunday this example of code library(ggplot2) library(scales) data.set <- structure(list(week.start = structure(c(15732, 15739, 15746, 15753, 15760, 15767, 15774, 15781, 15788, 15795, 15802, 15809 ), class = "date"), overtime.avg = c(2.8, 2.85666666666667, 2.18333333333333, 2.44666666666667, 2.04833333333333, 2.45833333333333, 2.12833333333333, 1.81666666666667, 1.82166666666667, 1.54333333333333, 2.09166666666667, 0.970833333333333)), .names = c("week.start&q

ios - About .h and .m files (how to manage) -

hey experienced programmers! id ask clean code :) id keep code clean , make nice, thats questions: 1)where should put #imports? principles: (and dont think good) #import frameworks should in .h #import .h files should in .m .h files should have @class, not imports (excluding frameworks uikit, etc) delegates should in .m @interface viewcontroller() <uialertviewdelegate> @end 2)where should put instance variables? private , protected variables must in .m public must in .h 3)where should put methods? public in .h private in .m (and yeah know "private methods" not private, hidden) (btw thats pretty obvious) 4)what #defines? global - in .h used in class - in .m 5)where should put nsnotification global identifiers , how organize them #define nsnotificationdatasourcedidloaddata @"nsnotificationdatasourcedidloaddata" in .h file in class send notification but .... apple has lot of private things in .h file in cases

How to use mobile wifi and data connection simultaneously for different purposes in android app -

i working on research task , need use wifi , mobile data connection simultaneously different tasks in android app. possible? if yes how? suggestions work-around appreciated. a bit late straight answer no. android automatically changes wifi when available because faster. sorry there maybe way if root device

.net - Adding a row to a dataset is not updating the database (C#) -

a simple, yet frustrating issue. i've bound datagrid local database play around , teach myself datasets , c#. binding data, no problem. custom fills (and sql selects), no problem. next comes adding record. so, add in following code: private void badd_click(object sender, eventargs e) { datarow newrow = abbtestdataset.tables["main"].newrow(); newrow["name"] = "simon"; newrow["age"] = 23; abbtestdataset.tables["main"].rows.add(newrow); } the datagrid updates no problem, data never committed database. i've searched high , low solution or may missing out on , nothing; @ least i've seen i'm doing right. so missing? undoubtedly stupid. i believe need use dataadapter send updated dataset database. check out links below more info: http://www.java2s.com/tutorial/csharp/0560__ado.net/usedatatabletoinsertarow.htm using ado.net beginners the

knockout.js - Implementing a Menu in Knockout - switching between views with different viewModels -

essentially trying implement robn's extremely simple template switcher http://jsfiddle.net/rniemeyer/xyz8m/ uses 'template' data binding. (---so wants code here - see fiddle complete code---) <div id="templatecontent" data-bind='template: { name: currentview() }'></div> var viewmodel = { currentview: ko.observable("template-1"), toggleview: function() { this.currentview(this.currentview() === "template-1" ? "template-2" : "template-1"); } }; ko.applybindings(viewmodel); i have seen lot of other simple examples doing , using same viewmodel class each loaded template. exception - robn's samplepresentation app (i don't have enough rep points post link) while impressive found hard connect noobie ko experience. think doing in section.activate() method, but, it's unclear me. i want use concept in real app, having binding context issues. here tr

spring - GenericJDBCException - Could not update -

i'm trying update record in database , i'm getting following error. i'm trying figure out error means. sqlcode -302 says 1 of values may have exceeded allowed length, have checked values being saved db - when took values , run query manually, records being updated. jdbcexception w org.hibernate.util.jdbcexceptionreporter logexceptions sql error: -302, sqlstate: 22001 jdbcexception e org.hibernate.util.jdbcexceptionreporter logexceptions db2 sql error: sqlcode: -302, sqlstate: 22001, sqlerrmc: null abstractflush e org.hibernate.event.def.abstractflushingeventlistener performexecutions not synchronize database state session org.hibernate.exception.genericjdbcexception: not update: [com.me.model.myclass#6849972133] @ org.hibernate.exception.sqlstateconverter.handlednonspecificexception(sqlstateconverter.java:82) @ org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:70) @ org.hibernate.exception.j

java - Is it possible to run selenium script from web browser? -

i have scrip (using python) submits form on www.example.com/form/info.php currently script will: - open firefox - enter name, age, address - press submit what want have web form (with name, age, address) on lamp , when user press submit adds options selenium script (to put www.example.coom/form/info.php) , submits directly in browser. possible? update: know possible using mechanize, because have tested out, doesnt javascript why using selenium. the script has run first , create browser session. afaik there no way take webdriver control of browser open.

c# - Json formatted string to list -

i have string this: {"label":{"en":"africa","de":"afrika"},"description":{"en":"continent","de":"irdischer kontinent"}} is possible convert list like: "label" - "en":"africa","de":"afrika" "description" - "en":"continent","de":"irdischer kontinent" thanks as others have suggested, looks you're trying process json document. recommend json.net this. however, can manipulate string if transformation simple , don't expect variation in input. 1 easy way this: var result = input.replace(":{", " - ") .replace("},", environment.newline) .replace("{", string.empty) .replace("}", string.empty);

Oracle out parameter cast - c# -

having issue older application supporting. data access csla .net , there line updates newly created entity id value out parameter. defined in database numeric(10,0). code looks this: oracleparameter opid = new oracleparameter("p_id", oracledbtype.int64); //... stuff , save new entity db _id = (long)opid.value; this used fine on windows xp version 9.x of odp .net. on windows 7 box latest version cast fails , return data type of parameter decimal despite being explicitly declared int64. looks me bug/weird behavior in new version of odp .net. there workaround or can fix issue, preferably without changing code? thanks! this issue further detailed on oracle forums here: https://forums.oracle.com/forums/thread.jspa?threadid=406872 ; there seems have been slight change affects how oracle data types being hadled. quick fix double cast (long)((oracledecimal)opid.value).

asp.net - Open XML - Word: Create tab with leading dots (.NET 3.5 - C#) -

Image
i want create tab leading dots in openxml word. do know how it? found: http://officeopenxml.com/wptab.php http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.tabchar.aspx don't know how translate c# code. so create paragraphproperties: paragraphproperties pproperties = new paragraphproperties( new tabs( new tabstop() { val = tabstopvalues.right, position = 4320, leader = tabstopleadercharvalues.dot } ) ); and added paragraph , works.

google cloud datastore - Persisting Collection<T> using Objectify4 on GAE -

i have been having issues persisting generic collection on google datastore using objectify4. e.g. @entity class animalinfo { @id string id; collection<animal> animals; } @entitysubclass class cat extends animal { string name; } @entitysubclass class dog extends animal { string name; } @entity class animal { @id string id; } how can persist animalinfo class , retrieve again. have tried: objectify.save().entities(animalinfo).now(); while fetching again: objectify.load().type(animalinfo.class).id(animalinfo.id).get(); doesnt have name field corresponding extended class cat or dog. this logical because animal class doesnt have field name . how work? generic interface ianimal (in place of animal class) better solution design-wise, doesnt work objectify needs concrete types. any solution above problem?? thanks in advance. shaun to summarize, looks want collection of references polymorphic entities. this: @entity class animalinfo { @i

Accessing a local MySQL instance in your GAE development environment for java using eclipse -

i new google app engine environment. starting project using google cloud sql. testing purpose need setup local mysql instance. have tried searching answer, didn't find helped me. if summarize question, trying access local mysql instance in gae development environment using java in eclipse. you have add mysql connector in app engine sdk folder. you can find connector there: http://dev.mysql.com/downloads/connector/j/ . then, have place in folder: appengine-java-sdk\lib\impl then have run local version of mysql (for example using easyphp). here sample of code use connect database (singleton) : public static connection getinstance() throws exception { if (connection != null && !connection.isclosed()) { return connection; } if (islocaltesting) { //mysql string url = "jdbc:mysql://127.0.0.1:3306/your_db_name"; connection = drivermanager.getconnection(url, "root", ""); } else { // google cloud sql

sql server - Function to evaluate which rows are not null and return an INT -

i trying calculate numeric value if rows checked in sql server. have done before on client side using .net code. trying within sql server script user based came me excel spread sheet looking input table. days of week example sun = 1 mon = 2 tue = 4 wed = 8 thr = 16 fri = 32 sat = 64 input table sysid sun mon tue wed thr fri sat ----- --- --- --- --- --- --- --- 1 0 0 1 0 1 0 0 2 1 1 1 1 1 1 1 3 0 0 0 1 0 0 1 desired result sysid dayofweek ----- --------- 1 20 2 127 3 68 without writing 128 case statements or writing values table , doing sum function...i thinking function pass in values of 7 fields , add them , return value. is there easier way this? if understand trying do, might work: select (case when sun=1 1 else 0 end) + (case when mon=1 2 else 0 end) + (case when tue=1 4 else 0 end) + (case when wed=1 8 else 0 end) + (case when thu=1 16 else 0 end) +