Posts

Reading file PHP using too much memory -

so, i'm trying parse text file has 24mb , 314134 lines. problem is, feel script using way memory. this code: if(file_exists($filepath)) { $data = file_get_contents($filepath); $lines = explode("\n", $data); foreach ($lines $line) { //split line. $spllitedline = explode(';', utf8_encode($line)); //get fields index. $localidade = !empty($spllitedline[3]) ? $spllitedline[3] : ''; $codigo_postal = $spllitedline[14] . '-' . $spllitedline[15]; $morada = (!empty($spllitedline[5]) ? $spllitedline[5] : ' ') . ' ' . (!empty($spllitedline[6]) ? $spllitedline[6] : ' ') . ' ' . (!empty($spllitedline[7]) ? $spllitedline[7] : ' ') . ' ' . (!empty($spllitedline[8]) ? $spllitedline[8] : ' ') . ' ' . ...

android - Error on ruOnUiThread inside asychtask -

i trying parse data server , compare data data in database... seems working fine... except getting same value comparing data change... i'll explain code... in below code, there textviews tv3 , tv4... comparing data ie, shopid changed, shows value first array of json... when tried debug, found the run() inside runonuithread calling after 2-3 loops... donno whats happening here... please somone ,e sort out issue... edit: while debugging when skip each line not showing error... when try skip breakpoints using f9 shows error... edit: 2: since code litle bit long, juz deleted som unwanted part... private bitmap downloadbitmap(string url) { httpurlconnection urlconnection = null; try { url uri = new url(url); urlconnection = (httpurlconnection) uri.openconnection(); int statuscode = urlconnection.getresponsecode(); if (statuscode != httpstatus.sc_ok) { return null; } inputstream inputstream = urlconnectio...

How tochange the text inside a link with jQuery -

i want change text inside link jquery when href attribute undefined. here code; <input type="text" id="sample"/><button id="button">submit</button> <table id="table" border="1"> <tr> <td>less 50</td> <td>less 100</td> <td>less 500</td> <td>less 1000</td> <td>more 1000</td> </tr> </table> js: $("#button").click(function() { var val=$("#sample").val();//alert(val) if(val<50){ var col1=val; }else if(val<100){ var col2=val; }else if(val<500){ var col3=val; }else if(val<1000){ var col4=val; }else if(val>1000){ var col5=val; } var row='<tr>'+ '<td><a href="#">'+col1+'</a></td...

c# - Multiple CheckedChanged event on programmatically added checkboxes -

i want able assign each checkbox it's own richtextbox i'm making richtextboxes, i'm making checkboxes how can "link" them together? for example : // richtextbox 1 - > checkbox 1 = false // richtextbox 2 - > checkbox 2 = true // richtextbox 3 - > checkbox 3 = true // richtextbox 4 - > checkbox 4 = false this code: int n = todoitems.count; richtextbox[] richtextboxes = new richtextbox[n]; checkbox[] checkboxes = new checkbox[n]; (int = 0; < n; i++) { //creating richtextbox richtextboxes[i] = new richtextbox(); richtextboxes[i].name = "tb" + i.tostring(); richtextboxes[i].text = todoitems[i].tostring(); richtextboxes[i].location = new system.drawing.point(130, (10 + (60 * i))); richtextboxes[i].size = new system.drawing.size(300, 50); richtextboxes[i].visible = true; rich...

Solving PDE system in Matlab: Derivatives on a mesh -

i using matlab solve system of coupled pdes, pdenonlin . i create mesh geometry (a square box circular hole in middle), , refine until : [p,e,t] = initmesh('defectgeom2'); [p,e,t] = refinemesh('defectgeom2',p,e,t); i solve system % solution: u = pdenonlin(b_s,p,e,t,c_s,a_s,f_s); % extract different functions full solutions (systems): np = size(p,2); % number of node points uk = reshape(u,np,[]); % each uk column has 1 component of u therefore have uk (in case 3) solutions. now want calculate integrals , derivatives of approximate solutions. tried interpolating uniform grid using tri2grid : x=linspace(-1,1,npts); y=x; psi=tri2grid(p,t,uk(:,3),x,y); theta=tri2grid(p,t,uk(:,1),x,y); theta_y=derivative(theta,1,2); psi_x=derivative(psi,1,1); and calculate: pressure = trapz(x,psi_x-cos(2*theta).*theta_y+sin(2*theta)); but gives me poor approximation, guess because of fact grid uniform whereas mesh finer around central circle , coarser elsewhere. i...

java - Why is there a delay in Spring AMQP Message dispatching from a filled Queue? -

i using spring amqp in message driven application. noticed there constant delay of around 300ms between invocations of message listener, though sure queue filled messages. logfile below shows delay between blockingqueueconsumer.nextmessage , blockingqueueconsumer.handle call blockingqueueconsumer.handledelivery thread in between: 2015-05-12 12:46:18,655 trace [simpleasynctaskexecutor-1] simplemessagelistenercontainer.doreceiveandexecute waiting message consumer. 2015-05-12 12:46:18,655 debug [simpleasynctaskexecutor-1] blockingqueueconsumer.nextmessage retrieving delivery consumer: tags=[{amq.ctag-wwui6qjs1fanfpm7j6givw=my-queue}], channel=cached rabbit channel: amqchannel(mybrokerip,1), acknowledgemode=auto local queue size=0 2015-05-12 12:46:18,967 debug [pool-1-thread-6 ] blockingqueueconsumer.handledelivery storing delivery consumer: tags=[{amq.ctag-wwui6qjs1fanfpm7j6givw=my-queue}], channel=cached rabbit channel: amqchannel(mybrokerip,1), acknowledgemode=auto local queue...

android - Update fragments in viewpager when a Spinner item is selected -

my goal create simple, multi-language application uses viewpager display fragments. have created : -"frensh_frag1,frensh_frag2,frensh_frag3 " french fragments -"english_frag1,english_frag3,english_frag3 " english fragments what want add spinner displays languages (fr, en), when choose "en" viewpager should display english fragments. how implement spinner code?! code far : public class mainactivity extends fragmentactivity { private viewpager pager; spinner spinner; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); pager = (viewpager) findviewbyid(r.id.viewpager); spinner = (spinner) findviewbyid(r.id.spinner); string[] language={"fr", "en", "sp"}; arrayadapter<string> stringarrayadapter=new arrayadapter<string> (this,android.r.layout.simple_spinner_dropdown_item,language); spin...