Posts

Showing posts from May, 2013

Autohotkey: modify text file without ever opening -

i'll start off saying i've sat around trying figure out 8hrs , i'm coming here ask help. i want able have text file starts @ 0 , increase 1 every time press hotkey. want happen without having file open. used counter. ken made point regard knowing initial value. if want add number @ bottom can use: fileappend, %counter%`n, c:\temp\counter.txt or if want have 1 number: filedelete, c:\temp\counter.txt fileappend, %counter%, c:\temp\counter.txt if want store variable, can use .ini files store various variables. iniwrite, %textcounter%, %a_scriptdir%\counter.ini, counter, nr iniread, textcounter, %a_scriptdir%\counter.ini, counter, nr

html - dynamic drop down form using JavaScript -

i'd have drop down form using javascript. need create question essentially. how works: person, home page, click "create question" , go create question page. on page, first question asks person "what type of question ask?" , then, via few radio buttons, can select type want, either "multiple choice", "select best" or "short answer". point, more of form appears…in other words, depending on type of question want ask, different set of criteria asked them fill out before submitting server question they'd ask. make sense? here form far: <!doctype html> <html> <head> <title>quick bump</title> <link href="styles.css" type="text/css" rel="stylesheet" /> </head> <body> <div class="center"> <h1 class="welcomeheader">create question:</h1>

activerecord - Rails many_to_many table not updating -

i'm not able many_to_many table update when create new site record. sites table updated, not sites_users. i'm expecting user_id , site_id added sites_users table when site created. my migration: class createtablesiteuser < activerecord::migration def create_table :sites_users, :id => false |t| t.integer :site_id t.integer :user_id end models: user.rb class user < activerecord::base attr_accessible :name, :email, :password, :password_confirmation, :user_id has_secure_password has_and_belongs_to_many :sites site.rb class site < activerecord::base attr_accessible :name, :site_key, :organization_id, :user_id, :site_id belongs_to :organization has_and_belongs_to_many :users sites_controller.rb def create @site = site.new(params[:site]) @site.organization_id = organization.where(:user_id => current_user.id) @user_id = current_user.id if @site.save flash[:success] = "new site created!" redir

Access an array value within an object in PHP -

i'm new php , trying access value of "contactid" following: object(stdclass)#2 (4) { ["contacts"]=> array(1) { [0]=> object(stdclass)#3 (18) { ["email"]=> string(24) "joewilliams@icontact.com" ["firstname"]=> string(3) "joe" ["lastname"]=> string(8) "williams" ["prefix"]=> string(3) "mr." ["suffix"]=> string(3) "jr." ["fax"]=> string(0) "" ["phone"]=> string(10) "8668039462" ["street"]=> string(21) "2365 meridian parkway" ["street2"]=> string(0) "" ["city"]=> string(6) "durham" ["state"]=> string(2) "nc" ["postalcode"]=>

C++ delete calls overloaded operator inside dylib (Xcode) -

i'm using xcode build c++ code where-in i'm calling delete destroy memory, have external lib loaded has delete operator overloaded, when call delete delete operator of lib called though not intended so. anybody has clue how prevent this? i have found decorated name operator delete lib, how tell xcode symbols? if define own operator delete in project code doesn't compile because of duplicate symbol error? anybody has clue on this? in advance help.

java - Recursion Driver Methods -

public class findsum { private static int sum(int n) { if (n==1) return 1; else return n + sum (n-1); } public static int getsum(int n) { if (n>0) return sum(n); else { throw new illegalargumentexception ("error: n must positive"); } } } according book, tests n>0 before execution. don't understand why case if test "if (n>0)" comes after algorithm. shouldn't 2 methods flipped in order accomplish test? the order they're written in doesn't matter, rather order of execution critical. since getsum explicitly calls sum if check successful, there's no worry check getting missed, long call getsum .

asp.net mvc - Why are changes made in my .NET MVC-4 solution not showing in the browser preview? -

so i'm running visual studio 2012 (win7) on vmware fusion. 50% of time change view not render in browser preview. drive me crazy. solution found kill webview.webserver40 app launches when click view in browser web build. seems issue working on mac virtual machine, running on pc doesn't have issue. if else has better solution great. it's annoying workflow @ least i'm yelling @ it. -- update if comes across this, found solution here: caching in asp.net development server also: http://support.microsoft.com/kb/911272 edit registry key: hklm\software\microsoft\asp.net\defaultdocumentinstalled 1 2 -- update #2 so fix worked moment , may have quirk. me installing iis express via microsoft web platform installer worked magic. no more issue. jesus. http://www.microsoft.com/web/gallery/install.aspx?appid=webmatrix

css - jQuery – enable/disable all style sheets on page on click -

is possible detect style sheets on current page click of ‘disable/enable css’ button , disable them on first click none of styling applies, , restore them once again on second click? idea jquery like, if it’s possible? $('link[rel="stylesheet"]').attr('disabled', 'disabled'); this should disable of them, opposite renable them: $('link[rel="stylesheet"]').removeattr('disabled');

ios - Want to Create String to Post Method -

i want pass string in post method.. the string @"functionname=getcourses_by_category&json={"course_cat_id":"8"}" from apple's docs on how send post data : nsstring *bodydata = @"functionname=getcourses_by_category&json={\"course_cat_id\":\"8\"}"; nsmutableurlrequest *postrequest = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:@"https://www.apple.com"]]; // set request's content type application/x-www-form-urlencoded [postrequest setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; // designate request post request , specify body data [postrequest sethttpmethod:@"post"]; [postrequest sethttpbody:[nsdata datawithbytes:[bodydata utf8string] length:[bodydata length]]]; // initialize nsurlconnection , proceed usual

android - addPreferencesFromResource -

i know might duplicate from: what use instead of "addpreferencesfromresource" in preferenceactivity? but still can not code work , appreciate help. can not the: "addpreferencesfromresource(r.xml.preferences);" work. preferences not resolved, though in r.xml folder. i followed example in above link letter. please help!! package com.example.oasisreference; import android.r; import android.r.xml; //import android.annotation.targetapi; import android.os.bundle; import android.preference.preferenceactivity; import android.preference.preferencefragment; public class prefs extends preferenceactivity { @override protected void oncreate(final bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); getfragmentmanager().begintransaction().replace(android.r.id.content, new mypreferencefragment()).commit(); } public static class mypreferencefragment extends preferencefragment { @override public void

ruby on rails - Where and how to handle Stripe exceptions? -

i'm building small proof of concept stripe , ruby on rails 3.2. far i've watched railscast on how implement stripe in ror app , it's working well. i've built app following railscast #288 billing stripe . users can add , edit credit cards , register classes , have credit card billed upon completion. now i've been testing stripe's numerous test credit cards , want catch many exceptions when raised. i'm using stripe's example errors in registration model show here: class registration < activerecord::base belongs_to :user belongs_to :session attr_accessible :session_id, :user_id, :session, :user, :stripe_payment_id validates :user_id, :uniqueness => {:scope => :session_id} def save_with_payment(user, stripe_card_token) if valid? if user.stripe_customer_id.present? charge = stripe::charge.create( :customer => user.stripe_customer_id, :amount => self.session.price.to_i * 100,

Deck of Cards issue -Java -

i having problems getting deckofcards class compile. keeps telling me cannot find symbol when pointing deck2.shuffle() , deck2.deal() . ideas why? import java.lang.math; import java.util.random; public class deckofcards { private cards[] deck; private int cardhold; public deckofcards() { deck = new cards[52]; int n = 0; (int = 1; <= 13; i++) { (int j = 1; j <= 4; j++) { deck[n] = new cards(i, j); n = n + 1; } } cardhold = -1; } public void shuffle() { // shuffles ands resets deck int = 0; while (i < 52) { int rando = (int) (5.0 * (math.random())); cards temp = deck[rando]; deck[rando] = deck[i]; deck[i] = temp; i++; } } public cards deal() { // if there more cards left in deck, return next 1 , // increment // index; return null if

drawing - OPENCV - Pixel count -

i load image in opencv. draw line point(x1,y1) point(x2,y2). how count pixels on line? try use int cvinitlineiterator(const cvarr* image, cvpoint pt1, cvpoint pt2, cvlineiterator* line_iterator, int connectivity=8, int left_to_right=0) you can find description here "the function initializes line iterator , returns number of pixels between 2 end points. both points must inside image. after iterator has been initialized, points on raster line connects 2 ending points may retrieved successive calls of cv_next_line_point point. points on line calculated 1 one using 4-connected or 8-connected bresenham algorithm."

javascript - Debugging in Jison -

i'm using jison write parser. grammar: { "program": [ ["statements eof", "return $1;"] ], "statements": [ ["statement", "$$ = $1;"], ["statements statement", "$$ = $1 + '\\n' + $2;"] ], "statement": [ ["expression newline", "$$ = $1 + ';';"] ], "expression": [ ["number", "$$ = yytext;"], ["expression expression", "$$ = $1 + ', ' + $2;"] ] } when run following error message: conflict in grammar: multiple actions possible when lookahead token number in state 9 - reduce rule: expression -> expression expression - shift token (then go state 5) states conflicts: state 9 expression -> expression expression . #lookaheads= newline number expression -> expression .expression expre

python - Trying to get a panel on wxPython to change a TextCtrl on another panel -

i in process of writing chat program integrates skype. have of legwork done, having issues notebook control in wxpython. want create new tab on notebook when user sends message, have working, issue have how reference textctrl on panel on tab? following code different project pulled online: import wx class page(wx.panel): def __init__(self, parent): wx.panel.__init__(self, parent) t = wx.statictext(self, -1, "this page object", (20,20)) class mainframe(wx.frame): def __init__(self): wx.frame.__init__(self, none, title="notebook remove pages example") pannel = wx.panel(self) vbox = wx.boxsizer(wx.vertical) hbox = wx.boxsizer(wx.horizontal) self.buttonremove = wx.button(pannel, id=wx.id_any, label="delete", size=(80, 25)) self.buttonremove.bind(wx.evt_button, self.onbuttonremove) hbox.add(self.buttonremove) self.buttoninsert = wx.button(pannel, id=wx.id_any, label="create", size=(80, 25

My PHP get YouTube video api function isn't printing anything -

just been crating api (as exercise) latest youtube video , nothing being printed. i'm new php , have started create myself website youtube_api.inc.php <?php function get_latestvideo($username) { if (true || (time() - filetime("{$globals['path']}/cache/video_cache.txt")) > 3600) { $videos = array(); $data = "http://gdata.youtube.com/feeds/api/users/{$username}/uploads?start-index=1&max-results=1&v=2&alt=json"; foreach (json_decode(file_get_contents("$data"))->feed->entry $video) { $url = (array)$video->link[0]; $videos[] = array( 'title' => $video->title->{'$t'}, 'desc' => $video->{'media$group'}->{'media$description'}->{'$t'}, 'url' => $url['href'], ); } file_put_contents("

Ruby on Rails: prevent new page execute through default application -

i'm beginning learn ruby on rails , know every time create new page in app/assets/views pages rendered out through layouts/application has html markup , <%= yield %> but if want create home page different page yield (or different layout aside default application page), how do won't have go through default application? thanks! there few ways achieve this. controller wide in controller, can use layout method class mycontroller < applicationcontroller layout :name_of_my_layout end this use app/views/layout/name_of_my_layout.html.erb layout actions under mycontroller you can pass method layout returns name of layout class mycontroller < applicationcontroller layout :random_layout private def random_layout %[layout1 layout2 layout3].sample end end the method random_layout determines layout used action under mycontroller per request. per render you can override above option passing layout option render calls. cl

c# - Passing an object in RedirectToAction -

i have controller has received post back, , has processed user has requested. build object, , now, want redirecttoaction.. return redirecttoaction() ("index", "location", r); where r named object working with. on target action, r null. public actionresult index(locationbyaddressreply location) now, read few posts on here this, battling understand. an option put forward wasl tempdata["myobject"] = myobject; but seems ... strange. not type safe. suitable way pass objects? yes can values using tempdata on redirect. method should looks like: public actionresult yourredirectmethod() { tempdata["myobject"]=r; return redirecttoaction() ("index", "location"); } and public actionresult index() { locationbyaddressreply location=null; if(tempdata["myobject"]!=null) { location=(locationbyaddressreply)tempdata["myobject"]; } } in way values of model pr

asynchronous - How to run multiple perl open commands asynchronously and display output in order -

i'm attempting run multiple ssh commands multiple servers asynchronously, i'd capture output commands , display them in order. throw in additional curveball, i'd pid3 run once pid2 complete, , pid4 run after first 3 commands complete. how best accomplished? example: // $pid1 , $pid2 should run asynchronously $pid1 = open(my $ssh1, "|ssh -t -t runuser\@$server{'app'} 'sudo chef-client'"); $pid2 = open(my $ssh2, "|ssh -t -t runuser\@$server{'auth'} 'sudo chef-client'"); // command should wait $pid2 complete. $pid3 = open(my $ssh3, "|ssh -t -t runuser\@$server{'auth'} \"sudo -- sh -c '$update_commands'\""); // command should wait $pid1-3 complete before running. $pid4 = open(my $ssh4, "|ssh -t -t runuser\@$server{'varn'} \"sudo -- sh -c '$varn_commands'\""); my (somewhat crude) solution far. feel there may more elegant way handle in pe

unix - How to instantly react to key pressing in C? -

i'm trying call function when user presses key, sending signal ctrl-c. idea doing something, in while loop, , actively listen for, say, 'f' key being pressed. when pressed, program stop performing loop , else because 'f' key pressed. is there way customize signal mapping? didn't have luck this. there seemed 1 or 2 available signals customization, need 3. if use getchar(), user needs press 'f' key , press enter key. them press 'f' key , not have press enter key. it similar using unix's more program user can press space bar go through pages. any appreciated! if reason not ncurses, can try following. you can use separate thread uses select() on stdin performs read() on stdin , parses user input; if key looking for, send signal (i.e. user1 or user2 unused) main thread. in signal handler, perform whatever operation looking on interrupt. note doing means code must interruptible interrupt not break computation.

Codeigniter - Please suggest me that how to add pagination in this search engine -

-- -- database: ci-intro create database ci-intro default character set utf8 collate utf8_general_ci; use ci-intro ; -- -- table structure table posts create table if not exists posts ( id int(11) unsigned not null auto_increment, title varchar(100) default null, body text, created datetime default null, modified datetime default null, primary key ( id ) ) engine=innodb default charset=utf8 auto_increment=6 ; -- -- dumping data table posts insert posts ( id , title , body , created , modified ) values (1, 'another day still looking', 'my lion ran off', '2013-04-02 08:20:20', '2013-04-03 12:43:49'), (2, 'a day', 'the lion in 1 piece.', '2013-04-02 08:20:44', '2013-04-02 08:20:44'), (3, 'thank god', 'everything belongs father', '2013-04-02 08:21:03', '2013-04-02 08:21:03'), (4, 'at seaside', 'we went down sea side, started raining!', &

regex - Remove everything before and after variable=int -

i'm terrible @ regex , need remove large portion of text except variable declaration occurs numerous times, id remove except instances of mc_gross=anyint. find what: [\s\s]*?(mc_gross=\d+|\z) replace with: \1 position cursor @ start of text replace all . add word boundaries \b around mc_gross=\d+ if think it's necessary.

jsf 2 - Dynamically generate rich menuitems inside rich context menu -

i trying dynamically generate rich menu items inside rich context menu component. here code: <ui:repeat var="group" value="#{mybean.groups}" > <div align="center"> <rich:panel> <h:graphicimage value="#{group.iconurl}"/> <rich:contextmenu attached="true"> <c:foreach var="child" items="#{group.children}"> <rich:menuitem label="#{child.name}" /> </c:foreach> </rich:contextmenu> </rich:panel> </div> </ui:repeat> i using tag library : xmlns:c="http://java.sun.com/jsp/jstl/core my problem menu items aren't being generated. have tried replacing c:foreach ui:repeat still won't work. i tried little experimentation eliminate factors. removed rich context menu , used ui:repeat <ui:repeat var="group" value="#{mybean.groups}" > &l

How to trace the flow in a python code without look through all the source code -

i'm new bie in python. wanna trace python project "youtube download" provides bunch of functions download youtube videos , wanna know when trigger 1 of method in project. "./youtube-dl <youtube_url> -t" it download youtube stream , save title. wanna know when trigger command functions called , don't want "know/trace" other functions not related command triggered. is there debug mode option, or kind of setting can let me job! thanks in advance^^

php - foreach loop for number of arrays -

code: foreach ($output $result) print_r($result); below output of above code: array ( [0] => 323 [1] => 323 [2] => 323 [3] => 323 [4] => 65 [5] => 65 [6] => 65 [7] => 65 [8] => 121 [9] => 121 [10] => 121 [11] => 121 ) array ( ) array ( ) array ( [0] => 656 [1] => 656 [2] => 656 [3] => 656 ) array ( [0] => 777 [1] => 777 [2] => 777 [3] => 777 ) array ( [0] => 321 [1] => 321 [2] => 321 [3] => 321 [4] => 434 [5] => 434 [6] => 434 [7] => 434 [8] => 400 [9] => 400 [10] => 400 [11] => 400 ) array ( ) array ( ) array ( [0] => 300 [1] => 300 [2] => 300 [3] => 300 [4] => 666 [5] => 666 [6] => 666 [7] => 666 ) array ( ) array ( [0] => 167 [1] => 167 [2] => 167 [3] => 167 ) i want print each array separately. trying nested foreach loop not getting required output. please help nested loop simple foreach ($output $outer) { foreach (

iphone - How many types of payment systems we can integrate to buy game levels through third party in iOS? -

i want integrate third party in-app sales credit systems in small gaming application. in application,there game levels. want give levels of gaming free, after levels, user should purchase levels. so, please suggest me process better integrating third party credit payment systems in gaming application out using apple default in-app purchase feature. possible this. in advance. check app store review guidelines, section 11 (i won't reproduce here). if use other apple's in-app purchase api app rejected. biggest companies (e.g. amazon) don't around rule. way might around handle payments outside app, such on website, , link app website. no guarantees apple wouldn't reject app anyway though.

plsql - Created Temporary Tables Dynamically -

i have scenario like, need create stored procedure in columns come dynamically. based upon columns temporary tables should created. actually, scenario did in sql server , have migrated sql server database oracle. thanks if want create table dynamically, you'd need use dynamic sql begin execute immediate 'create global temporary table table_name( col1 number, col2 number )'; end; that being said, mistake directly port sql server code creates temporary tables oracle. not work same way sql server code does. first off, temporary tables in oracle visible every session unlike sql server local session. means if have 2 sessions calling stored procedure, they'd both try create temporary table , second 1 fail (things worse assuming dropping temporary table @ end of procedure rather letting thousands of temporary tables accumulate). creating tables inefficient process in oracle given amount of latching required. oracle's assumption not creating o

Lotus notes agent runs slower in server compared to development PC -

i have attendance recording system has 2 databases, 1 current, archiving. server processes attendance records, , puts records marked completed archive. there no processing done in archive database. here's issue. 1 of requirement build blank record each staff every day, attendance records put into. agent calls few procedures , checking within database. of current, there 1,800 blank records created daily. on development pc, processing each records takes 2 3 seconds, translates average of hour , half. however, when deployed on server, processing each records takes 7 seconds, translates 3 , half hours complete. have had instances when agent takes 4.5 5 hours complete. note in both instances, agents scheduled. there no other lotus apps in server, , server free , idle of time (no other application except windows server , lotus notes). there cause additional processing time compared on development pc , server? your process generating 1800 new documents every day, , have s

sql - Possible to eliminate this sub query? -

i have documents table fields as documentid int - pk , autoincrement laststatuschangeddatetime - datetime jurisdictionid - int documentstatusid - int now want bring in computed column named canchangestatus . queue. if document first in it's status can changed. query: select d.documentid, ( select cast(case when d.documentid = v.documentid 1 else 0 end bit) ( select top 1 documentid documents jurisdictionid = d.jurisdictionid , documentstatusid = d.documentstatusid order laststatuschangeddatetime ) v ) canchangestatus documents d index there on jurisdictionid , documentstatusid . culprit subquery - way trying calculate canchangestatus . there way can speed or convert subquery join because joins mostly faster subqueries? you should able aggregate function (example on sqlfiddle ): select documentid, case when row_number() on ( partition jurisdictionid, documentstatusid

How to add a file to download into Jenkins/Hudson plugin -

i need add file downloading plugin, provides build step. want put link html file build step field, , able paste link e-mails etc. let's assume simple, plain plugin project, pom.xml having this: <groupid>my.jenkins.plugins</groupid> <artifactid>my-special-plugin</artifactid> <name>my special plugin</name> name of downloadable myspecialtool.exe question: where put file under plugin project source what download url, assuming jenkins @ http://ciserver:8080 what write html file link "properly" (if different above) hoping reference answer: clear, short , to-the-point. store data want able address 'web data' in src/main/webapp in plugin project. that directory should addressable /plugin/<name of plugin> (from ' jenkins continuous integration cookbook ') answers enumerated questions: put file under src/main/webapp , perhaps in sub-folder, so: src/main/webapp/download/myspecialtool.

jsf - Do I need to use MyFaces if I am using JBoss seam in my application? -

we have legacy jsf based web application uses seam. deployed on websphere 7.0. not have myfaces jars in /web-inf/lib , has seam jars. so, how application jsf jars? how jsf work in application? jsf being part of java ee specification bundled in java ee compliant application servers glassfish, jboss as, websphere , weblogic. not need bundle in webapp. your confusion coming, because you've ever worked barebones jsp/servlet containers tomcat or jetty , experienced need manually provide jsf libraries. true, barebones jsp/servlet containers ships jsp/servlet (and el) libraries, not other java ee artifacts jsf, ejb, jpa, etcetera. that's why need bundle along own webapp. so, concretely answer question: no, not need bundle jsf webapp if bundled target server. please note regardless of jsf implementation (you explicitly mentioned myfaces, while question/answer applies other jsf implementations mojarra).

Issue in vertical scrollbar in silverlight datagrid -

i'm using silverlight datatgrid in project checkbox in header selectall option. while scrolling datagrid vertically, header checkbox status changing randomly content checkbox status remains correct. please me if come across issue. <control:datagrid.rowgroupheaderstyles> <style targettype="control:datagridrowgroupheader"> <setter property="propertynamevisibility" value="collapsed" /> <setter property="background" value="lightgray" /> <setter property="foreground" value="#ff404040" /> <setter property="sublevelindent" value="15" /> <setter property="template"> <setter.value> <controltemplate targettype="control:datagridrowgroupheader"> <primitives:datagridfrozengrid name="root" background="{templatebi

android - Why is the first line always crossed out? -

in application use simplecursoradapter . if checkbox.ischecked() text should strikethrough. why first line crossed out, if checkbox not checked public class mainactivity extends activity { // button btncalendar; //*******************************************8 string[] names = {"Иван", "Марья", "Петр", "Антон", "Даша", "Борис", "Костя", "Игорь", "Анна", "Денис", "Андрей"}; //button buttonaddtask; final string tag="states"; final string ten = "ten"; textview txtdatatasktoday; string id_for_listtsk_today; listview lvmain_today; string[] arr_date; sharedpreferences spref; static cursor c; private listview listview = null; sqlitedatabase db; //public static string id_for_listtsk_today; // static sqlitedatabase db; mysqlcursoradapter adapter = null; //***********************************************8 @override protected void oncreate(bundle sav

mysql - Why the difference in performance when using one index versus multiple indexes -

let's have table named impression having 3 fields id site_id timestamp all 3 fields int . have run following query select count( * ) c impression timestamp<unix_timestamp(str_to_date('09,07,2009','%d,%m,%y')) , site_id=11 findings if define 2 separate indexes, 1 on timestamp , 1 on site id results slower. on data set result takes 0.13 s calculate. however if define 1 composite index includes both fields in 1 results faster 0.0002 s question why indexed fields have under 1 index? if have 2 separate indexes them why don't both of them used note yes explain query that's not question, explain suggests observed, why have 1 index per query

c++ - Trouble reading file using getline (noob) -

i'm noob c++ student. i'm having trouble reading file array structure. class assignment not need 1 code me, want know i'm doing wrong. text file i'm reading formatted such: giant armadillo#443#m hawaiian monk seal#711#m iberian lynx#134#m javan rhinoceros#134#m etc... using getline() works correctly reading string '#' delimiter, not work int or char . how read int or char while checking delimiters? thanks, sorry if isn't written clearly, or formatted properly. i'm brand new so. #include <iostream> #include<string> #include <fstream> #include <cstdlib> using namespace std; //create new structure struct endangered { string name; int population; char species; }; int main () { endangered animals[200]; //initialize animals (int i=0; i<50; i++) { animals[i].name=" "; animals[i].population=0; animals[i].species=' '; } ifstream myfile; myfile.open("animals.txt&quo

Convert string to array of integers and vice versa in JavaScript -

i have array, each cell of can keep 4 bytes (2**32). array presents memory of vm write in js. have string. 1 place can keep string - memory describe above. i decided present strings in memory c-strings (with special symbol nul end of string). current implementation looks ugly , asking advice, there way improve approach? maybe there other way it? part of code, converts string array: // demomemory presents memory model var demo_volume = 16; var demomemory = new array(demo_volume); (var = 0; < demo_volume; i++) demomemory[i] = 0; // convert string hexidecimal string var string = "hello, world!", hexstring = ""; (var = 0; < string.length; i++) { hexstring += string.charcodeat(i).tostring(16); } // convert hexidecimal string array of strings // each element of array presents 4 symbols var hexstringarray = hexstring.match(/.{1,8}/g); // add nul (0x00) symbols complete strings while (hexstringarray[hexstringarray.length - 1].length != 8) { hexstr

lua - Corona: Restart scene when game completed -

when player has completed game, scene restarted, i.e want reload current scene. have tried storyboard:reloadscene() without success. tried purge scene , reload it, without result. local function oneveryframepoop() if(foodballs) = foodballs.numchildren, 1, -1 local ball = foodballs[i] if(ball.y > 200 , not(ball.isbeingpooped)) ball.isbeingpooped = true local function tempremove() if(foodballs.numchildren)then ball:removeself() ball = nil print("removed") end end physics.removebody(ball) transition.to(ball, {time = 2000, y = 400, oncomplete = tempremove}) audio.play(fartsound) end end if(foodballs.numchildren == 0 , food.numchildren == 2) reward.playrewardanimation() runtime:removeeventlistener("enterframe", oneveryframepoop) ti

asp.net - JQuery Calendar control only appears once when clicking on textbox -

i have jquery calendar works on webpage once. after select date , try click on textbox change date calendar doesn't appear. here code ` $(document).ready(function () { $("#<%= txtdatepicker.clientid %>").datepicker(); }); ` <asp:textbox id="txtdatepicker" runat="server" ontextchanged="txtdatepicker_textchanged" autopostback="true" ></asp:textbox> ok figured out. because of autopostback. when using autopostback partial page load therefore datepicker did not work. added datepicker binding pageload function , works now..... thanks answers guys function pageload() { $("#<%= txtdatepicker.clientid %>").datepicker(); }

xml - How do we acces simpleXMLElement object in php -

simplexmlelement object ( [0] => cem ) there simplexmlelement object this. tried accessing $object->0 , $object->{0} . giving php error. how access out changing format. from print_r output might not obvious: simplexmlelement object ( [0] => cem ) this single xml element containing string cem , example: <xml>cem</xml> you obtain value casting string (see basic simplexml usage docs ): (string) $object; when have simplexmlelement object , you're unsure represents, it's easier use echo $object->asxml(); output xml , analyze using print_r alone because these elements have lot of magic need know read print_r output properly. an example above: <?php $object = new simplexmlelement('<xml>cem</xml>'); print_r($object); echo "\n", $object->asxml(), "\n"; echo 'content: ', $object, "\n"; // echo cast string automatically output: simplexmlelement

ssrs 2008 - Getting the values in between -

in report builder 3.0 have string of comma separated values e.g. "value1, value2, value3, value4". have used split() first , last position how in between "value1" , "value4". can remove first , last position in array split function creates? result looking "value2, value3". i can think of couple of methods: =trim(split(fields!valuestring.value, ",")(1)) & ", " & trim(split(fields!valuestring.value, ",")(2)) similar you're doing, concatenates 2 values together. trim helps avoid issues whitespace. =trim(mid(fields!valuestring.value , instr(fields!valuestring.value, ",") + 1 , instrrev(fields!valuestring.value, ",") - instr(fields!valuestring.value, ",") - 1)) this uses string manipulation based on comma positions. again trim used clean whitespace. neither of these perfect when input string unexpected format, depending on data checks might required,

android: how to get memory usage (ram) of a given PID programically -

i want log ram usage of given application @ given time rate. wrote code full memory value used not know how memory usage of given pid. please me out this code used memory activitymanager localactivitymanager = (activitymanager)getsystemservice("activity"); activitymanager.memoryinfo localmemoryinfo = new activitymanager.memoryinfo(); localactivitymanager.getmemoryinfo(localmemoryinfo); log.i("",string.valueof(localmemoryinfo.availmem)); i think can using public memoryinfo[] getprocessmemoryinfo (int[] pids), not know how code since im android beginer activitymanager localactivitymanager = (activitymanager)getsystemservice(context.activity_service); // use context.activity_service not literal "activity" list<activitymanager.runningappprocessinfo> procsinfo = localactivitymanager.getrunningappprocesses(); int[] pids = new int[procsinfo.size()]; (int = 0; < procsinfo.size(); i++) { activitymanager.runningappproc

asp.net - the name 'windows' does not exist in the current context -

i trying use windows.location redirect page in web application,but shows me above mentioned error,so files should added page use same?any appreciated. yes, there no window.location in asp.net. instead try bool value true in response.redirect response.redirect("default.aspx",true);

networking - xserver didn't show result from Xsensor -

Image
i have build example xsensor 420cc plug , put sensor board on it, on other side serial board build xsniffer (tosbase) mote need put on 520mip serial usb. to see message send form mote 1 mote 2, try open cygwin terminal , type xserve -device=com4 open serial device there nothing display !! i have try change (tosbase) (xmeshbase) see if useful, mote (xmeshbase) use on serial usb, still there no output on xserve. note: when try open moteveiw output terminal give me receive ""heartbeat received"" no field or data ! i use xmesh send packet information, didn't understand meaning of these data ? feel same !! this appeared ?