Posts

c++ - Stream of Integers arriving at specified interval need to look sorted -

interview question: there stream of integers arrives @ specified intervals (say every 20 sec). container of stl use store them integers sorted? reply map/set when there no duplicate or multimap/multiset when there duplicate. better answer if exists? use multiset if want preserve duplicates. if don't want preserve duplicates, use set .

actionscript 3 - Action Script 3: Addchild within an already added child issue -

my issue error when function addspotlight called. typeerror: error #1010: term undefined , has no properties. @ bubbleboy_fla::maintimeline/addspotlight() @ bubbleboy_fla::maintimeline/policeheli() @ flash.utils::timer/_timerdispatch() @ flash.utils::timer/tick() my code this: //adding helicopter function addhelicopter(xlocation: int, ylocation: int, passspeedx, passspeedy): void { var helicopter: helicopter = new helicopter(xlocation, ylocation, passspeedx, passspeedy); back.addchild(helicopter); helilist.push(helicopter); playfly(); } //adding spotlight function addspotlight(xspotlightlocation: int, yspotlightlocation: int, spotlightspeedx): void { var spotlight: spotlight = new spotlight(xspotlightlocation, yspotlightlocation, spotlightspeedx); back.helicopter.addchild(spotlight); spotlightlist.push(spotlight); } the reason doing because helicopter can destroyed , spotlight gets removed @ same time, if don't destroy helico...

python - Issue in numpy array loop for central difference -

input array reference, u = array([[ 0., 0., 0., 0., 0.], [ 0., 1., 1., 1., 0.], [ 0., 1., 1., 1., 0.], [ 0., 1., 1., 1., 0.], [ 0., 0., 0., 0., 0.]]) python function using loop import numpy np u = np.zeros((5,5)) u[1:-1,1:-1]=1 def cds(n): in range(1,4): j in range(1,4): u[i,j] = u[i,j+1] + u[i,j-1] + u[i+1,j] + u[i-1,j] return u above function cds(5) provide following result using for loop , u=array([[ 0., 0., 0., 0., 0.], [ 0., 2., 4., 5., 0.], [ 0., 4., 10., 16., 0.], [ 0., 5., 16., 32., 0.], [ 0., 0., 0., 0., 0.]]) same function using numpy def cds(n): u[1:-1,1:-1] = u[1:-1,2:] + u[1:-1,:-2] + u[2:,1:-1] + u[:-2,1:-1] return u but same input array(u), function cds(5) using numpy provide different result., u=array([[ 0., 0., 0., 0., 0.], [ 0., 2., 3., 2., 0.], ...

Javascript Non-Repeating Number Generator Sometimes Returns Multiple Numbers -

i'm trying create random non-repeating number generator numbers 13. when run following function varying out puts, here results of running function 5 times using button click, , code. can't understand why it's repeating numbers. var checkifrandom = new array(); function getrandom(){ var randomnum= math.floor(math.random()*13); if(checkifrandom.indexof(randomnum) !== -1){ getrandom(); }else if(checkifrandom.indexof(randomnum)==-1){ checkifrandom.push(randomnum); } console.log(randomnum); }; //results 2 //click 1 7, 2 //click 2 6 //click 3 1 //click 4 5,7,1 //click 5 [2, 7, 6, 1, 5]//after 5 clicks logged checkifrandom array console in chrome. you're using recursion, means it's storing previous, non-unique numbers in stack , still logging them. move console.log() else if reads: function getrandom(){ var randomnum= math.floor(math.random()*13); if(checkifrandom.indexof(randomnu...

qt - Can't compile while Google Drive is running -

i compile stuff using qt , run google drive time. if compile project once, debug little , recompile quickly, google drive uploading files can't compile - can last minute due australian upload speeds. quit google drive, forget open again , next day files aren't synced when university. i never had problem when using dropbox (i assume copies files before uploading). any way around menacing problem?

virtualbox - What is the "vagrant-host-manager start id" in the /etc/hosts file? -

i using vagrant(1.7.2), virtualbox(4.3.26), along puphpet on project. using vagrant plugin vagrant-host-manager programmatically write /etc/hosts file on vagrant up , vagrant halt . i notice plugin provides information in comments of /etc/hosts ## vagrant-hostmanager-start id: 26c12a6f-22fd-4053-g193-77707p90318 (obfuscated id) i thought perhaps id string going contain name of running virtual machine, appear in virtualbox gui. appears not case. know how may associate above id 1 several machines. i want know because have several vm's containing same ip address , set of host names, therefore cannot discern vm has written what.

asp.net - Can i use c# to call ajax -

i have ajaxtoolkit pop this: <ajaxtoolkit:modalpopupextender id="modalpopupextender1" runat="server" targetcontrolid="button4" behaviorid="popup1" popupcontrolid="panel1" dropshadow="true" cancelcontrolid="button3" onokscript="okbuttonclick" backgroundcssclass="backgroundstyle" /> how can make execute inside btnreject_click @ c#? protected void btnreject_click(object sender, eventargs e) { //code here } at first make this. tb.text = "reject"; tb.cssclass = "btn btn-default"; tb.onclientclick = "javascript:$find('popup1').show();"; tb.usesubmitbehavior = false; tb.causesvalidation = false; tb.click += new eventhandler(btnreject_click); but find execute pop first. so, i'm looking way make execute after button click