Posts

Showing posts from July, 2010

PowerShell XML Parsing & Export -

i'm new using powershell, , joined stackoverflow. have project @ work try parse xml file , export specific nodes csv file. need *<group>name"unique name"* , member task # exported multiple entries in file exported .csv. the xml file looks below example several entries group name & associating task #: <settings><tasks><groups> <group name="some name"> <notes>some notes here</notes> <member t="task">159711687</member> <member t="task">584643293</member> <member t="task">465828474</member> <member t="task">262255905</member> <member t="task">121466829</member> <member t="task">257067112</member> </group> <group name="some name 2"> <notes>testing</notes> <member t="task">865485927</member> <member t="task">363

java - Saving SSID Data in SQLite Database Causes Force Close -

i'm attempting update database additional data (the users current ssid) when attempting save database - entire application force closes. i understand there nullpointer exception being caused when saving data - have no idea i've done wrong cause it. logcat: 04-04 21:24:08.351: e/androidruntime(10745): fatal exception: asynctask #2 04-04 21:24:08.351: e/androidruntime(10745): java.lang.runtimeexception: error occured while executing doinbackground() 04-04 21:24:08.351: e/androidruntime(10745): @ android.os.asynctask$3.done(asynctask.java:299) 04-04 21:24:08.351: e/androidruntime(10745): @ java.util.concurrent.futuretask.finishcompletion(futuretask.java:352) 04-04 21:24:08.351: e/androidruntime(10745): @ java.util.concurrent.futuretask.setexception(futuretask.java:219) 04-04 21:24:08.351: e/androidruntime(10745): @ java.util.concurrent.futuretask.run(futuretask.java:239) 04-04 21:24:08.351: e/androidruntime(10745): @ android.os.asynctask$serialexecutor$1.r

rubygems - Creating a Ruby Gem -

what comprehensive source on learning how create ruby gem? is paid solution e.g., book? i'm not finding on internet , on here except basic tutorials don't cut it. the definitive guide rubygem’s own make own gem (plus other guides ) along gem specification reference . the bundler’s bundle gem command useful creating skeleton project.

how to change the target frame link in html using script(java or some other script)? -

i new forum. have few image buttons on top, when click each image open links on bottom frame(object).. have tried few lines. got 1 static link working. want different links each button. <html> <head> <meta http-equiv="content-language" content="zh-cn"> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title>new web</title> </head> <body> <div style="margin: 0 auto; width:1107px; height:1512px;">  <p><img border="0" src="images/home.jpg" name="home" onclick="onbutton1();" width="95" height="94">&nbsp; <img border="0" src="images/googlemaps.jpg" name="googlemap" onclick="onbutton1();" width="91" height="90">&nbsp; <img border="0" src="images/restaurants1.jpg" width="93"

jquery - Clear array and text box with javascript -

each time checkbox checked, below function called. problem need function should clear data available here. let me explain problem first: the concept of program update text box checkbox value - if 2 check boxes checked, text box have 2 values in , on. i need function clear data on check box when click 3rd check box needs show 3rd checkbox's value removing first , second text area. should happen without reloading page <script> function chkcontrol(j){ var textbox = document.getelementbyid("list"); var textbox1 = document.getelementbyid("val_id"); var values = []; var val_id=[]; if(document.getelementbyid(1).checked) { values.push('a1'); val_id.push('1'); } if(document.getelementbyid(2).checked) { values.push('a2'); val_id.push('2'); } if(document.getelementbyid(3).checked) { values.p

extjs - ServiceStack MiniProfiler Ajax Requests Logging -

Image
so, in index.cshtml page, when load page have: @inherits viewpage <!doctype html> <html> <head> <script type="text/javascript" src="ext-all-debug.js"></script> <script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app.ext.js"></script> <script type="text/javascript" src="dump.js"></script> @servicestack.miniprofiler.profiler.renderincludes().asraw() </head> <body> </body> </html> all good, can see profiling index, bunch of extjs, , 1st ajax call servicestack on server side (in /api/session). now, in extjs form have customers tab when click sends ajax request /api/customers , have tab when click calls /api/orders . but, when start click on, customers tab, miniprofiler not add subsequent ajax requests list more?

php - Warning: strpos() [function.strpos]: Empty delimiter in foreach statement -

i have read topics regarding strpos() issues cant find 1 fix mine. here code. foreach($titles_array $k=>$v) { if(strpos($subject,$v) !== false) { $i++; $asd[$titles['id']] = $i; } } the script works , results i'm looking error comes : warning: strpos() [function.strpos]: empty delimiter i read might empty string or value in array i've checked them both , didnt found empty string/value. appreciate help. best ! the "empty delimiter" warning occurs when second parameter strpos empty. have empty value in $titles_array . i have reproduced warning here: http://3v4l.org/rnu3q try print_r($titles_array) right before foreach loop.

view - IE9 compatibility mode -

i have issue website not working in ie10 (some pages using iframes). in ie10, can click on 'compatibility view' button , works fine again. to avoid users having this, tried insert meta tag in header of master page (it's .net website), , in root web.config (in system.webserver config block). tried ie=9, ie-8... nothing works. browser not interpreting tag? know sees because when tag there, 'compatibility view' icon disappears. missing? ie 9 – compatibility: <meta http-equiv="x-ua-compatible" content="ie=9"> if want ie 8: <meta http-equiv="x-ua-compatible" content="ie=8"> if want both: <meta http-equiv="x-ua-compatible" content="ie=9; ie=8;">

Set the index of a Python array -

i'm trying set index of array in python, isn't acting expected: thething = [] thething[0] = 0 '''set thething[0] 0''' this produces following error: traceback (most recent call last): file "prog.py", line 2, in <module> thething[0] = 0; indexerror: list assignment index out of range what correct syntax setting index of array in python? python lists don't have fixed size . set 0 th element, need have 0 th element: >>> thething = [] >>> thething.append(12) >>> thething [12] >>> thething[0] = 0 >>> thething [0] javascript's array object works bit differently python's, fills in previous values you: > x [] > x[3] = 5 5 > x [undefined × 3, 5]

static analysis - Removing useless lines from c++ file -

there many times when debugging, or reusing code, file starts acquire lines don't anything, though may have done @ 1 point. things vectors , getting filled, , go unused, classes/structs defined never used, , functions declared, never used. i understand in many cases, of these things not superfluous, might visible other files, in case, there no other files, extraneous code in file. while understand technically speaking, invoking push_back something, , therefore vector not unused per se, in case, result goes unused. so: there way this, either using compiler (clang, gcc, vs, etc) or external tool? example: #include<vector> using namespace std; void test() { vector<int> a; a.push_back(1); } int main() { test(); return 0; } should become: int main(){return 0}; our dms software reengineering toolkit c++11 front end used this; presently not off shelf. dms designed provide custom tool construction arbitrary source languages, , contai

php - Pause JavaScript function onclick -

hi new javascript , ajax. the idea page when user clicks appropriate area in image in map calls javascript function myfunction1 when entry in 'field_x' '0' - function updates 'field_x' '1' through ajax ('field_x' starts '0' entry). then when user next clicks same area in map myfunction2 called because entry in 'field_x' '1' - , updates 'field_x' '2'. and on... the ajax call works fine , updates 'field_x' correctly when appropriate function called individually. however problem (with code have it) when user clicks map 3 functions called in succession straight away (and 'field_x' becomes '3'). not sure how pause between functions , wait next click user. i have abbreviated code in functions best can functions other things well. appreciated. php user page <?php function request_data(){select field_x table_x; } $q = request_data(); ?> <map> <area

Using a variable in a PHP MySQL Query -

i user variable inside of php mysql query represent clause so: $where= name=mark , address=4; $query= "select * clients $where"; am doing correct? if not, correct so? your php method correct, need single quotes around string in sql , need wrap string php variable quotes, variable should this: $where = "name = 'mark' , address = 4"; $query = "select * clients {$where}";

amazon web services - accessing AWS S3 from a desktop app securely -

i have data multiple users inside single s3 account. desktop app has authentication system let app know user , folder access on s3. desktop app has access code whole s3 folder. somebody told me not secure since hacker break request app s3 , use credentials download data. is true? , if how can avoid it? (he said need client server in aws cloud isn't clear me... ) btw. using boto python library access s3. thanks i found this : don't store aws secret key in app. determined hacker able find eventially. 1 idea have web service hosted somewhere sole purpose sign client's s3 requests using secret key, requests relayed s3 service. therefore users authenticate agaist web service using credentials control. re-iterate: clients talk directly s3, requests "rubber-stamped"/approved you. i don't see s3 flat structure - if use filesystem notation "folder/subfolder/file.ext" keys. vanity urls supported s3 see http://docs.amazonwebservices

c# - Get The Full List Of Objects In A Dictionary Values -

i have dictonary: private dictionary<int, icar> _icarsdic; the object icar contains list of objects: public interface icar { int carid { get; set; } string carname { get; set; } list<ibrandsdetails> brandsdetails { get; set; } } i write function returns me in single list brandsdetails in _icarsdic values. i sure linq (don't want write ugly loop) i'm new appreciate help. thanks! use eneumerable.selectmany list<ibrandsdetails> list = _icarsdic.selectmany(r => r.value.brandsdetails) .tolist();

Stop a TeamCity build via REST call -

is possible cancel running build via rest api? i've got integration fetches running builds, , terminate builds of given type if failed. know how list failing builds of given type, how pass stop command? maybe not rest api, if here (towards bottom in comments section) there's 'undocumented' feature lets on http.

jQuery + ASP.NET: jQuery click event doesn't fire -

i'm having issue using jquery within asp.net website. want bind common click handler multiple similar elements (generated through listview familiar asp.net). assumption use class selector follows (as example): $('.standard-group').click(function () { alert($(this).attr("id")); }); this relates series of divs having class: <div class="standard-group"> content </div> <div class="standard-group"> other content </div> furthermore, content generated inside contentplaceholder , merged master page (2 nested master pages actually). i've tried putting click handler between <script></script> tags inside second contentplaceholder injects it's content <head> section of page, tried putting content in main contentplaceholder no avail. ends happening generated page loads correctly , can inspect source , see function there, no event raised. suspect it's master page/server

validation - Symfony / Doctrine: add annotiation to Attribute defined in 'MappedSuperclass' -

edit: learned, there's annotiation missing subclass ('here it's id', thx greenleaf). actual problem is, don't know, how override this, can't work. original: i migrated symfony 2.0 application symfony 2.2 , 'invalid entities'-information in dev-profiler, regarding unidirectional one-to-many-association. when using console with php console doctrine:schema:validate i receive 2 messages: * association \entity\watched#reference refers inverse side field \entity\reference#id not defined association. * association \entity\watched#reference refers inverse side field \entity\reference#id not exist. i think, wrong, because 'id' defined in superclass. app stills runs fine on old db (created symfony 2.0). classes (simplified): code: select all /** * @orm\mappedsuperclass * @orm\haslifecyclecallbacks */ abstract class superclassabstract { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strat

java - How to generate Junit report using Junit Core -

i required run few junit tests, using junit core. able accomplish task, unable fetch junit report run. can 1 please suggest me way in can achieved. not sure, if want, link lead create report ant task http://blog.varunin.com/2010/03/ant-script-for-generating-junit-report.html

symfony - Download file functional test on Symfony2 -

with symfony2, how test (functional test) file has been downloaded on client's side? have tried following code wrong. my controller: public function downloadaction($picture_id) { $fichier= $this->uploaddir.$picture_id; if (($fichier != "") && (file_exists($fichier))) { $content = file_get_contents($fichier); $response = new response(); $response->headers->set('content-type', 'application/octet-stream'); $response->headers->set('content-disposition', 'attachment;filename="'.$picture_id); $response->setcontent($content); return $response; } } test code: public function testupload() { $ch = curl_init(); curl_setopt($ch, curlopt_header, 0); //curl_setopt($ch, curlopt_httpheader, array("content-type: image/jpeg")); curl_setopt($ch, curlopt_verbose, 1); curl

visual c++ - Windows with mapped drive -- _stat() fails to detect existence of the file -

summary: _stat() function says there not existing file when drive letter mapped unc path. details: on windows system, there unc path \\computer\sharename\disk_m\the_subdir\file.txt and mapped way: net use m: \\computer\sharename\disk_m then file.txt can accessed m:\the_subdir\file.txt , , can see content in editor. the problem need test file existence in program. use following function: bool isfile(const std::string & path) { struct _stat stat; if (_stat(path.c_str(), &stat)) return false; // call returns -1 errno enoent return (stat.st_mode & _s_ifreg) != 0; } when debugging, have found _stat calls findfirstfile function: /* call find match file */ findhandle = findfirstfile((_tschar *)name, &findbuf); if ( findhandle == invalid_handle_value ) { _tschar * pbuf = null; ... , fails find file here. what problem? doing wrong? how can enhance detection of existence of file? (the code

java synchronized keyword needed on primitive getter / setter method? -

i read java code, , found these functions: synchronized void setconnected(boolean connected){ this.connected = connected; } synchronized boolean isconnected(){ return connected; } i wonder if synchronization makes sense here, or author didn't understand need synchronized keyword? i'd suppose synchronized useless here. or mistaken? the keyword synchronized 1 way of ensuring thread-safety. beware: there's (way) more thread-safety deadlocks, or missing updates because of 2 threads incrementing int without synchronization. consider following class: class connection { private boolean connected; synchronized void setconnected(boolean connected){ this.connected = connected; } synchronized boolean isconnected(){ return connected; } } if multiple threads share instance of connection , 1 thread calls setconnected(true) , without synchronized possible other threads keep seeing isconnected() == false . synchronized keyword guarante

r - Maximum likelihood estimation for ARMA(1,1)-GARCH(1,1) -

following standard textbooks on arma(1,1)-garch(1,1) (e.g. ruey tsay's analysis of financial time series), try write r program estimate key parameters of arma(1,1)-garch(1,1) model intel's stock returns. random reason, cannot decipher wrong r program. r package fgarch gives me answer, customized function not seem produce same result. i build r program helps estimate baseline arma(1,1)-garch(1,1) model. adapt baseline script fit different garch variants (e.g. egarch, ngarch, , tgarch). appreciated if provide guidance in case. code below r script estimating 6 parameters of arma(1,1)-garch(1,1) model intel's stock returns. @ rate, glad know thoughts , insights. if have similar example, please feel free share extant code in r. many in advance. emily # r script offers suite of functions estimating volatility dynamics based on standard arma(1,1)-garch(1,1) model , variants. # baseline arma(1,1) model characterizes dynamic evolution of return generating process. # base

CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Load report failed - VB.NET 2003 -

anybody know why below error exist? crystaldecisions.crystalreports.engine.loadsavereportexception: load report failed from comments windows\temp, caused application pool's identity not having access c:\windows\temp (and possibly reports folder). you can solve problem giving application pool credentials have necessary permissions, or giving read write permissions "network user" c:\windows\temp folder (and again, possibly reports folder). the reason why folder required crystal runtime creates dynamic copy of report @ runtime , places in %temp% folder. temp folder copy (with guid appended original file name) shown in web browser. design , useful feature ensure live report safe. following this, have proper cleanup after loading every report because they stay there , fill temp folder!

ios - Tab Bar appearing after popping a view controller -

im developing ios application, , in app im using tabbar controller. , within tab bar controller im navigating view controller. before pushing view controller im setting property of controller viewcontroller.hidesbottombarwhenpushed = yes; and im navigating view controller has tab bar @ bottom. the problem when pop view controller view controller tab bar appears in view too. there way hide tab bar when popping view controller? itll great if can me out this. thanks in advance. in case viewwillappear method usefull. in firstviewcontroller put code -(void)viewwillappear:(bool)animated { self.tabbarcontroller.tabbar.hidden = yes; } so when secondviewcontroller poped out call method , bottom bar hidden .

HTML5 drag & drop text: preventdefault vs move -

i have 2 contenteditable divs formatted content (e.g. paragraphs in bold/italic text etc.) , move selected text 1 another. works natively, want "clean" moved text when dropped, e.g. remove formatting ("<b>hello</b>" become "hello"). decided use html5 drop event this: drophandler = function(e) { text = e.datatransfer.getdata('text'); if (document.caretrangefrompoint) { range = document.caretrangefrompoint(e.clientx, e.clienty); } else if (document.createrange && oe.rangeparent) { range = document.createrange(); range.setstart(oe.rangeparent, oe.rangeoffset); } range.insertnode(document.createtextnode(text)); return false; }; it works , puts "cleaned" (plain) text correct position, selected text in source contenteditable div not deleted - because of default behaviour prevented "return false" - desired text move becomes text copy. how can achie

php - Regex - escaping ' -

i'm trying parse string , extract values. suddenly, i'm stuck with symbols here: here code, describe situation: // example string $string = "@set('var', 'value')"; // regex i'm using extract values $regex = '@set\((.+),(.+)\)/' // result i'm getting array("'var'", "'value'") // desired result array("var", "value") any ideas? you matching character .+ rule. if don't want quotes in result, avoid them. rewrited rule: $regex = "/@set\('([^']+)',\s*'([^']+)'\)/"

ios - Is it posible to conditionally disable NSValueTransformer for NSManagedObject attribute? -

specifically, have nsmanagedobject "statuscode" attribute set transformable, , reversible value transformer subclass covert nsstrings nsnumbers , vice versa. idea use value transformer receive json , string "status" key in json automatically maps nsnumber represents status code in nsmanagedobject. conversely if upload nsmanagedobject server, @ point status attribute transformed nsnumber string json. so far good. but, if want able simple int out of nsmanagedobjec's status property, can , enums in code? is, i'd lie cover 3 cases: mymanagedobject.status = [jsonresponse valueforkey:@"status"] (should use transformer nsstring -> nsnumber) [jsonforupload setvalue:mymanagedobject.status forkey:@"status"] (should use transformer nsnumber->nsstring) from elsewhere in code, along lines of: if(mymanagedobject.status & statusinprogress) ... statusinprogress enum. i'm thinking temporarily disable value transformer, have

ios6 - what is differences between If-Modified-Since and lastUpdated in passbook web service reference -

i doing server updating pass in passbook. can register , unregister server. next, have serial of pass , latest version of pass when pass updated. differences between if-modified-since , lastupdated ? don't know how them ? database or else ? if-modified-since http header send .pkpass bundle. if not distribute pass web server, passbook web service should send in response " get latest version of pass " request. lastupdated tag store in database indicates when .pkpass bundle last changed. both of these should match same point in time. convention send if-modified-since header rfc 1123 formatted date , store lastupdated tag timestamp, although fould acceptable store formatted date.

ServiceStack & Swagger - ApiMember as Path and Query -

i'm searching solution following problem, concerning swagger integration in servicestack. i have requestobject required property id. want provide following routes: [route("/user/byid/{id}", "get", summary = @"test", notes = "test")] [route("/user/byid", "get", summary = @"test", notes = "test")] basically should leave choice of providing id in query string or path serviceconsumer. the swagger ui correctly displays 2 routes, not testable both ways, because api-member attribute not allow specify parametertype 'path' or 'query'. source: https://gist.github.com/johannesferner/5317496 is there way, provide api-member specification, according route, or define valdid path , query? like this: [apimember(name = "id", parametertype="path,query", description = "user id", datatype = "int", isrequired = true)] in cases find easies

javascript - Sum the contents of many dropdowns when any of them change -

i have several dropdowns on page, , contain numbers. when user change 1 of these, need go through of them , sum numbers. how jquery? <select id="number1"> <option value="1">1</option> <option value="3">3</option> </select> <select id="number2"> <option value="1">1</option> <option value="3">3</option> </select> <select id="number4"> <option value="1">1</option> <option value="3">3</option> </select> i've tried like: $('select[id*="number"].change(function() { // when 1 dropdown change $('select[id*="number"].change(function() { // go through them var current = $(this); // add current value array }); }); $.each(arr,function() { total += this; // sum items }); but doesn't quite work expected. tips? tha

installer - Why do I need to specify a new guid for a version upgrade in wix -

i've updated our wix install scripts per previous question/answer how implement wix installer upgrade? . idea prevent older version 'downgrading' newer version. have parts of wix file like: <product id="a_guid" <upgrade id="18626be5-521c-4b58-ab8a-54baddf66679"> <upgradeversion property="newerversiondetected" minimum="$(var.version)" includeminimum="no" onlydetect="yes" excludelanguages="yes" /> </upgrade> <customaction id="newerversionfound" error="can't downgrade." /> <installexecutesequence> <custom action="newerversionfound" after="findrelatedproducts">newerversiondetected</custom> <removeexistingproducts after="installinitialize" /> </installexecutesequence> i have 2 v

npapi - NPRuntime plugin says Missing Plug-in in Safari(Windows) -

i have developed npruntime plugin, ok, not initialized in safari. registered plugin in mozillaplugins registry key, works fine chrome/ff/opera, safari writes the plugin missing, although found plugin in list of isntalled safari plugins. doing wrong ? that's real hard say. safari on windows isn't supported real apple, don't bother supporting myself. if it's important i'd recommend adding logging in npp_ methods (and np_ functions too) , see getting called; find out if loads plugin. if doesn't go browser wants during startup act didn't find @ all. you use process monitor see if trying load file or not.

javascript - Generate a url for youtube search -

how can use javascript or php generate url youtube, searches videos on specific user account best title match on top? i using code: <!doctype html> <head> <meta charset="utf-8" /> </head> <script type="text/javascript"> function mysearch() { var elem=document.getelementbyid('inputsearchquery'); var url="http://www.youtube.com/user/queenvevo/videos?query="+encodeuricomponent(elem.value); var win=window.open(url, '_blank'); win.focus(); } </script> <body> <h2>enter search string (user: queen)</h2> <input id="inputsearchquery" type="text" value="the show must go on"> <button type="button" onclick="mysearch()">search</button> </body> the problem youtube not place best title match @ top! video "the show must go on" on 13th place, , expecte

osx - iOS Emulator for Windows -

this question has answer here: iphone emulator windows allows installation of new apps [closed] 4 answers is there ios emulator windows? need 1 instead of buying macbook, that.i tester use instead of buying macbook. sorry noob question. nope, official way buy mac development. there's thing called hackintosh, not recommend installing software without licence using it. piracy bad. buy mac.

java - Could not load org.bouncycastle.jce.provider.JDKKeyPairGenerator$RSABeanInfo -

while build application getting below error. search online, did not find solution .......... apr 05, 2013 2:46:34 org.apache.catalina.loader.webappclassloader validatejarfile info: validatejarfile(/cisco/software/apache-tomcat-7.0.37/webapps/rmsportal-0.1/web-inf/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. see servlet spec 2.3, section 9.7.2. offending class: javax/servlet/servlet.class apr 05, 2013 2:46:46 org.apache.catalina.loader.webappclassloader loadclass info: illegal access: web application instance has been stopped already. not load org.bouncycastle.jce.provider.jdkkeypairgenerator$rsabeaninfo. eventual following stack trace caused error thrown debugging purposes attempt terminate thread caused illegal access, , has no functional impact. java.lang.illegalstateexception @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1599) @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1558) @ java.lang.

java - SQLite returned rows count is zero -

public class sqliteprovider extends sqliteopenhelper { private static sqlitedatabase sqlitedatabase ; public sqliteprovider ( context context ) { super ( context , database_name , null , database_version ) ; } @override public void oncreate ( sqlitedatabase sqlitedatabase ) { try { . sqlitedatabase = . getwriteabaledatabase ( ) ; . sqlitedatabase . execsql ( table_create ) ; . sqlitedatabase . close ( ) ; } catch ( exception exception ) { log . ( log_tag , "exception `" + exception . tostring ( ) + "`" ) ; } } private void insert ( string column1value , string column2value ) { try { sqlitedatabase = . getwritabledatabase ( ) ; sqlitedatabase . execsql ( query_to_insert ) ; sqlitedatabase . close ( ) ; } catch ( exception exception ) { log . ( log_tag , "exception `" + except

php - how to parse the json array elements using for loop to get the values one by one -

i have json array wherer pasre json till last element using loop number of array elements in json array ,i have more 3 objects in anarray ,so confused how parse json till last element, can idea count($json); echo count; for(i=0;i<l=count($json);i++) { print value of each key } i stuck ,because there no fixed lenght json getting server response may return 1 object 1 may twice or thrice or many ,so thought better loop ,as json contain more 1 json 3 keys ,such country can have more 1 state,and 1 state can have more 1 district ,plaese me,i stuck question last 2 days thank you an idea : function printjson($json) { foreach($json $index=>$value) { if(is_array($value)) { printjson($value); } else { echo 'value :'.$value.'<br />'; } } } $stringjson = "{'location':[{...}]}"; //for example printjson(json_decode($stringjson));

function - Python: How to import information from a .csv file to python as a list with tuples inside? -

i new programming please excuse shallow knowledge coding. have .csv file can open excel. each row represents person's name , details (like address, phone number , age) each detail in different columns. whenever move onto new row person's detail. i want import information python such each row (i.e. every detail of person) in 1 tuple (with each detail separated ',') , want tuples in list. list tuples inside them. i have started coding opening file don't know how implement each detail detail of person in tuple , tuples in list. using python 2.7. def load_friends(f): """ takes name of file containing friends information described in introduction , returns list containing information friends in file. load_friends(var) -> list """ openfile = open('friends.csv', 'ur') if f == 'friends.csv': openfile = open('friends.csv', 'ur') lines = openfile.readlines() print lines openf

c - Different typedef for same information -

i working on piece of code , encountered : typedef jobject jthread; typedef jobject jthreadgroup; what significance of different typedef similar entry ? it allows have 2 different names same type. there (at least) 2 different reasons you'd want this: in code, want reader see type of data we're dealing with. after all, "thread" diffferent "group of threads", if underlying type representing them different. ability change type 1 of types without affecting other. if @ later stage, decide "jthreadgroup" better new type, can change without affecting "jthread". imagine have small game, count score in integer type. have count of players: typedef int scorecount; typedef int playercount; later on, decide need small number, short count players: typedef short playercount; same idea using "jobject", different base-type, possibly make easy understand.

javascript - Random Number, Math.floor(...) vs Math.ceil(...) -

i've seen lot of code random numbers generated like // random integers in interval [1, 10] math.floor(math.random()*10 + 1) anyway, feel i'm missing something. why don't people use more succint way math.ceil(math.random()*10); ? i tried test randomness , seems true far. in fact, subsequent code // generate random integers 1 4 var frequencies = [ 0, 0, 0, 0, 0 ]; // not using first place var randomnumber; ( var = 0; < 1*1000*1000; ++i ) { randomnumber = math.ceil(math.random()*4); frequencies[randomnumber]++; } ( var = 1; <= 4; ++i ) { console.log(i +": "+ frequencies[i]); } prints out 1: 250103 2: 250161 3: 250163 4: 249573 what missing? quick ot: there more succint way declare , initialize frequencies? mean frequencies[5] = { 0 }; c++... as stated in mdn reference math.random() returns floating-point, pseudo-random number in range [0, 1) is, 0 (inclusive) not including 1 (exclusive), can scale desired rang

c# - MVC JsonResult updating progress -

this question has answer here: implementing progress bar long running task implemented asp.net mvc 2 asynccontroller 1 answer mvc 4 webapp, jquery i want show progress of lenghty procedure. the following gets called json takes several seconds... basically, is: [httppost] public jsonresult update(var x) { return json(new { result = "working", message = "waiting on server" }); var y = contactanotherserver(x); return json(new { result = "working", message = "crunching data" }); var finished = dosomethingwithdata(y); return json(new { result = "ok", message = "done" }); } obviously terminate on first return-statement. how done ? thank you! to "roll own" this, need 3 separate jsonresult methods , complex javascript function. ie: controller public jsonresul

jar - App works fine in android 2.3.7 and not in 4.1.2 -

i have app works fine in android 2.3.4, 2.3.6 , 2.3.7 doesn´t in android 4.1.2 or 4.2.2 (i have no more devices) the app calls jar file returns result, when test app in 2.3.7 make call jar , takes result when android 4.1.2 forces close. it´s quite weird because difference os because app same. the jar file makes call internet, don´t think mistake thanks again everybody! the jar file makes call internet, don´t think mistake => sorry dude problem here, said app working fine in < 2.3 versions not in >2.3, reasons behind failure networkonmainthreadexception . now, why exception being raised whenever run app in >2.3 version device? => networkonmainthreadexception occurs whenever application attempts perform networking operation on main thread. solutions: below 2 solutions resolve issue: 1) standard way make webservice call implementing asynctask . 2) lazy way of handling turn check of: strictmode.threadpolicy policy = new strictmode.th

How do I fire an event in VB.NET code? -

i have form has start button (to allow users run processes on , on if wish), , want send btnstart.click event when form loads, processes start automatically. i have following function btnstart.click event, how tell visual basic 'pretend has clicked button , fire event'? i've tried going simple, works. however, visual studio gives me warning variable 'sender' used before has been assigned value , i'm guessing not way it: dim sender object btnstart_click(sender, new eventargs()) i have tried using raiseevent btnstart.click , gives following error: 'btnstart' not event of 'myproject.myformclass code imports system.componentmodel partial public class frmprogress private bw backgroundworker = new backgroundworker public sub new() initializecomponent() ' set backgroundworker bw.workerreportsprogress = true bw.workersupportscancellation = true addhandler bw.dowork, addressof bw

symfony - Access to inherit class attribute from DQL in Symfony2 -

i have abstract class product , inherited class productwithrecurrency: /** * @orm\table(name= "product") * @orm\entity(repositoryclass="acme\storebundle\entity\repositories\productrepository") * @orm\inheritancetype("joined") * @orm\discriminatorcolumn(name="product_kind_id", type="integer") * @orm\discriminatormap({"1" = "productfoo", "2" = "productwithrecurring"}) */ abstract class product { } /** * * @orm\table(name="product_with_recurring") * @orm\entity( repositoryclass ="acme\storebundle\entity\repositories\productrepository") */ class productwithrecurring extends product { /** * @var recurring $recurring * * @orm\joincolumn(name="recurring_id", referencedcolumnname="id", nullable=false) */ protected $recurring; } i need mixed products , have "recurring" entity information when product instance

asp.net - Apply Different leaf node styles at same level in Treeview -

Image
i in need of showing directory structure using tree view control dynamically.i able tree view there problem styles. tree view looks this. but problem (in image) machine types , mother board reports @ same level,but want show different icon machine type(i want folder icon) , motherboard report (file icon).actually generating structure database using web.site map. my treeview code in aspx file follows. <asp:treeview id="treeview1" runat="server"> <rootnodestyle imageurl="~/treeview/images/folder/folder.gif" /> <parentnodestyle imageurl="~/treeview/images/folder/folder.gif" /> <leafnodestyle imageurl="~/treeview/images/folder/file.gif" /> </asp:treeview> so can body me out.. thanks you can use imageurl property of each node achieve : eg: <asp:treenode imageurl="image.jpg"></asp:treenode>

asp.net - css position of button in menu -

Image
i have menu menu looks : <div class="menucontainer"> <div id="titlebardiv" style="float: left;"> <a>item 1</a> <div id="container"> <input type="button" value="0" class="masterpagenotifier" style="height: 30px;"onclick="notifierbuttonclicked()" /> <input type="hidden" value="" class="mehidden" /> <ul class="selectbox" /> </div> <a>item 2</a> <a>item 3</a> <a>item 4</a> <a>item 5</a> <div> <div> as can see in between have div button inside, on click of button, ul class="selectbox" slide down , show items. problem here can menu work on itself, add button in between, button moving down 1 row, , when click on button .menucontainers background gets stretched. want make facebook when notification button clicked.i

javascript - Binomial sub arrays -

i have array n length. want take possible k (0 for example, if have a's length five: [1,2,3,4,5] and if k = 3, algorithm must give me b array. [1,2,3 ] [1,2, 4 ] [1,2, 5] [1, 3,4 ] [1, 3, 5] [1, 4,5] [ 2,3,4 ] [ 2,3, 5] [ 2, 4,5] [ 3,4,5] length of b equal n!/k!(n-k)! ('!' means factorial, newtons method) i'm using javascript, in tags included it, it's algorithm, not necessary written in javascript. below copy-paste 1 of projects. don't know if still works ;) var choose = function choose_func(elems, len) { var result = []; (var i=0; i<elems.length; i++) { if (len == 1) { result.push([elems[i]]); } else { var remainingitems = choose_func(elems.slice(i+1, elems.length), len - 1); (var j=0; j<remainingitems.length; j++) result.push([elems[i]].concat(remainingitems[j])); } } return result; }; var result = choose([1,2,3,4,5], 3) /*result = [[1,2,3],[1,2,4],[1,2

python - remove something from each individual element from the array -

'145,153,8,1.35659494835128,155,c,h,h,h,h,h,h,h,h,h,h,h,h,h,c,x,x,x,1.000,0.000,0.000,0.286,0.429,0.000,0.286,0.000,0.286,0.571,0.000,0.143,0.000,0.143,0.000,0.143,0.429,0.286,0,2,0,0,3,1,0,1,3,3,1,0,1,1,0,x,x,x,1,3,0,0,3,1,0,1,3,3,1,0,3,3,0,x,x,x,3,1,3,3,0,3,4,3,0,0,3,4,2,1,4,x,x,x,0.265,0.213,0.523,0.155,0.265,0.052,0.374,0.155,0.290,0.232,0.097,0.381,0.000,0.187,0.174,0.077,0.348,0.213,0.143,0.143,0.000,0.000,0.000,0.143,0.000,0.000,0.000,0.143,0.143,0.000,0.000,0.000,0.143,0.000,0.143,0.000,0.000,0.000,e,e,e,e,e,4,4,3,4,3,3,3,3,3,1,0,1,2,0,3,0.077,0.052,0.039,0.045,0.013,0.065,0.052,0.065,0.026,0.026,0.065,0.058,0.006,0.071,0.058,0.071,0.052,0.019,0.039,0.103,0,0,0,2,-4,-1,2,-2,-3,-3,-3,3,-3,-4,0,2,2,-5,-3,-3,-2,-6,-6,-5,-6,-5,-5,-5,-6,-2,-4,-5,-1,-3,8,-3,-4,-7,-6,-1,0,-2,-1,2,-4,1,4,-3,-1,-3,0,1,0,-1,-3,0,-2,-4,-2,-3,1,-1,0,3,-4,1,2,-2,-1,-3,-4,2,-3,-4,-3,2,0,-5,-3,-2,-3,-5,-5,-5,-4,-4,-5,-6,-5,5,3,-5,4,0,-4,-4,-3,-4,-3,1,1,1,-2,0,-3,-1,5,-3,-2,-1,-2,1,-2,-4,-3,-1,-1,-2,-3

nullpointerexception - Android Canvas drawcolor throws Null pointer exception -

developing small android game (2.1 till 4.2 support), below code throws java.lang.nullpointerexception exception at canvas.drawcolor((0xffaaaaaa); public class maingamepanel extends surfaceview implements surfaceholder.callback { public void render(canvas canvas) { canvas.drawcolor(0xffaaaaaa); droid.draw(canvas); } } here stack trace java.lang.nullpointerexception @ com.rdx.play.maingamepanel.render(maingamepanel.java:186) @ com.rdx.play.mainthread.run(mainthread.java:54) the exception inconsistent, might causing issue? many thanks. surfaceholder.lockcanvas() allowed return null (cos thread doesn't have same lifetime surface). bet aren't handling possibility in thread function.

__ in Ocaml extracted from Coq -

ocaml code extracted coq includes (in cases) type __ , function __ defined follows: type __ = obj.t let __ = let rec f _ = obj.repr f in obj.repr f the documentation says in past, such type defined unit (and __ taken () ) there exist (rare) cases value of type __ applied value of type __ . __ uses undocumented functions of obj module ocaml, seems defined totally polymorphic function eats arguments (whatever number). is there documentation regarding cases __ cannot eliminated , values of type applied values of same type, both theoretical (construct coq terms elimination impossible) , practical (show realistic case occurs) point of view? the references cited in readme give nice overview of erasure problem. specifically, both this report , this article exaplain in detail how type schemes , logical parts of cic terms erased, , why 1 must have __ x = __ . problem not __ may applied itself, may applied anything @ all . unfortunately, not @ clear if having b