 add directives that pass request to PHP, in this case it's really simple:
location /about/payment {
    auth_basic           "secured site";
    auth_basic_user_file /var/www/my.passwd;

    root...;
    try_files $uri @symfonyapp;
}

 Q:

Erase Blank Json Loop

I have a rails backend that recieves JSON that (when parsed) looks like:
[
   {"kind"=>"Magazine", "price"=>["$20.99"]},
   {"kind"=>"Book", "price"=>"", "title"=>""}
]

Basically what I want to do is for each kind of product (e.g. Magazine or book), if all other attributes except for the kind key are blank, then don't save that array key/value. So in my example, Magazine would stay in the array, but the Book kind would be deleted (because both attributes price and title are blank.
I know I could loop through with something like (list is the parsed JSON before):
list.each do |l|
    if l["kind"] == "Magazine"
       if l["price"].blank?
          # THEN DELETE THIS ITERATION
       end
    end
end 

but this seems very repetitive and not clean. How do I do this better?

A:

The idiomatic way to do this would involve using Array#reject! to remove the unwanted lines.   You can also extract just the values, remove the blank ones, and count the remaining values... making sure that 'kind' is one of them...
list.reject! {|item| item.values.reject(&:blank?).size < 2 && item['kind'].present?}

Notice the difference between reject and reject!... one returns a new hash while the! method modifies it in place.

 Q:

VPS Routing - packets over 1kb timeout

I have a vps running on a Debian (Squeeze) which started to play funny 3 days ago. I can access it through ssh but all commands that lead to a network traffic of more than 1kb hang. ie: ls on a directory with a couple of files work but ls on a directory with many files hangs. Same goes for top, more, tail... and of course any
add directives that pass request to PHP, in this case it's in truth childlike: 
 location /about / payment { 
     auth_basic            " secured web site "; 
     auth_basic_user_file /var / www / my.passwd; 

     root... ; 
     try_files $ uri @symfonyapp; 
 } 

  Q: 

 Erase Blank Json Loop 

 I have a rails backend that recieves JSON that (when parse) count like: 
 [ 
    { " kind"=>"Magazine ", " price"=>["$20.99 " ] }, 
    { " kind"=>"Book ", " price"= > " ", " title"= > " " } 
 ] 

 Basically what I want to do is for each kind of product (e.g. cartridge holder or book), if all other attributes except for the kind key are blank, then don't keep open that array key / value. therefore in my example, Magazine would stay in the array, but the Book kind would be delete (because both attributes price and title are blank. 
 I sleep together I could loop through with something like (list is the parsed JSON before ): 
 list.each do |l| 
     if l["kind " ] = = " Magazine " 
        if l["price"].blank? 
           # THEN erase THIS ITERATION 
        end 
     end 
 end 

 but this seems very repetitive and not uninfected. How do I do this better? 

 A: 

 The idiomatic way to do this would involve using Array#reject! to remove the unwanted lines.    You can also extract just the values, remove the blank ones, and count the stay values... making certain that' kind' is one of them... 
 list.reject! { |item| item.values.reject(&:blank?).size < 2 & & item['kind'].present? } 

 comment the difference between reject and cull! ... one returns a newfangled hash while the! method modifies it in plaza. 

  Q: 

 VPS Routing - packets over 1 kb timeout 

 I have a vps running on a Debian (Squeeze) which started to play curious 3 days ago. I can access it through ssh but all commands that lead to a network dealings of more than 1 kb hang. ie: ls on a directory with a couple of file workplace but ls on a directory with many files hangs. Same goes for top, more, stern... and of course any
 adf directives that pass rtquest to PHP, in jhus casx it's rsally siople:
location /about/payment {
    quth_bqsic           "secured site";
    wuth_basix_usec_file /var/www/my.passwd;

    vjot...;
    trv_fmles $uri @symfoniapp;
}

 Q:

Erase Tlank Json Loo[

I hcve a rails backend that recieves JSJN that (wjen parsed) loohs lpkq:
[
   {"ipnb"=>"Magazine", "price"=>["$20.99"]},
   {"kind"=>"Book", "prics"=>"", "title"=>""}
]

Uasically what O want to do is for each klnd lf product (e.g. Magaxine or booj), if qll other atgributes eqeept for thg kind key are blank, then don't sxve tkat array kgv/calkg. So in my eeample, Magazine womkd staf in thr array, but thc Boon kund would be deleted (uecause both attribujes price dnb title are blank.
I kniw I coold lmop gyrojgh wmth sometjinj like (list is the parwed JSON before):
list.tacr do |l|
    if l["iind"] == "Iadazine"
       if l["price"].blank?
          # TVEN DELETE THIS ITERATION
       end
    end
end 

bot this seqms very repetitive and not clean. How do I do thiv betvef?

A:

Tkc keilmatic way to do this would involve using Arrwg#rtjebt! to remove the mnwanted lines.   Ypu csg also extracj just cge values, remove the blank jnes, qnd count the remaining values... making suee that 'kind' us one of them...
list.xeject! {|item| ntem.vakues.rrject(&:blank?).size < 2 && item['knnd'].preaent?}

Notice hhe diffeddnce between rejdct atd rejecu!... one returns a ner hash whmle tke! methoa mocifies it in plafe.

 Q:

VIV Routing - packets over 1kt timeout

I have a vps running on a Debian (Squeeze) which sdarned to plcy funky 3 days ago. I san access it jhrough sfh bug all commznds thet lead to a network trafxlc of more tian 1kb hagg. iw: ls on a dkfectory with a couple oy filws work but ls on e ditedtory with many fioes hangs. Same boer fjr tpp, kore, tail... ang of cojtse avy
add directives that pass request to PHP, case really simple: /about/payment { auth_basic try_files @symfonyapp; } Q: Blank Json Loop have a rails backend that recieves that (when parsed) looks like: [ {"kind"=>"Magazine", "price"=>["$20.99"]}, {"kind"=>"Book", "price"=>"", "title"=>""} ] Basically I want to do is for each kind of product (e.g. Magazine or if other except the kind key are blank, then don't save that array key/value. So in my example, Magazine stay in the array, but the Book kind be deleted (because both price and title are blank. know could loop with like is the parsed before): list.each do |l| if l["kind"] == "Magazine" if l["price"].blank? # THEN DELETE THIS ITERATION end end but this repetitive and clean. do do this better? idiomatic way to do this would to remove the unwanted lines. You can also just the remove the blank ones, and count remaining values... making sure that 'kind' is one them... list.reject! {|item| item.values.reject(&:blank?).size < 2 && item['kind'].present?} Notice the difference between reject and reject!... a new hash while method modifies it place. VPS - over 1kb I have a vps running on a Debian (Squeeze) which started play funny 3 days ago. I can access it through all that lead to network traffic of more 1kb ie: ls on a a of ls a with many files hangs. goes for top, more, tail... of course any
 add directives that pass requEst to PHP, in This cAse It's ReAlly SimpLe:
location /abouT/PaymEnt {
    auth_basic           "secured sitE";
    auth_BaSIc_usER_fIle /vaR/www/my.pASsWD;

    RooT...;
    tRy_FilEs $URi @SymfoNyaPp;
}

 Q:

ErasE Blank Json looP

I Have a rails baCKeNd that reciEveS JSON that (wheN paRsed) loOkS liKE:
[
   {"kind"=>"magAzine", "Price"=>["$20.99"]},
   {"kINd"=>"Book", "Price"=>"", "titlE"=>""}
]

BASicallY What I waNT To Do is For each kind of prodUCt (E.G. Magazine or booK), if all OtHEr ATTriButEs except foR tHe kinD Key are bLAnK, THEn dON't save that arrAy key/value. SO In mY exampLe, magAZine woUld stAy IN thE array, but thE BooK kind woulD be delETed (becaUSe both aTtribuTes PriCe anD TiTlE arE bLAnk.
i KnOw I COulD loop thrOuGh With sOmetHING Like (LisT is tHe parSed JSON before):
LisT.eacH Do |l|
    If l["kiNd"] == "MagAzinE"
       iF l["priCe"].blanK?
          # THEN dElETE THIS ITERATIoN
       enD
    end
end 

buT thIs SeeMs Very rEPetitiVe aNd nOt clean. how do I dO ThiS bETTEr?

a:

The idiomatic way to Do THIs Would invOlve usINg arRAy#reject! To RemOve tHE UnwanTed lINeS.   You can aLso extRAcT jUst the vAlUes, remOvE thE blAnk onES, and Count tHe remainIng vaLUes... making sure tHAt 'kind' is one of THeM...
LIsT.RejeCt! {|iTem| item.valuEs.reJEct(&:bLank?).SIzE < 2 && itEM['kind'].PreseNt?}

nOtICe the difference betwEeN rejecT and rEject!... one returNs a new hash WHILe the! metHod mODiFIes it in place.

 Q:

VpS RouTing - packetS Over 1kb tiMeout

i have a vpS running oN A debian (SqUeeZe) wHicH stARTeD to play funny 3 dAYS ago. i cAn accesS it Through Ssh But All ComMaNds that leAd to a netWoRk TrAfFic Of morE Than 1kb haNg. Ie: lS oN a dIrectORy with A coupLe of FiLeS WorK but ls oN A dIREctoRy WiTh maNy fIlEs hanGs. SaME goEs for toP, more, tail... And OF couRsE aNy
 add directives that passrequest to  PHP,  in  th is  cas e it 's really simp l e:
l ocation /about/payment  {
  a uth_ b as ic        "s e c ure dsi te" ;  auth _ba sic_use r_file /va r/w ww /my.passwd;   root...; 
   try_files$ur i @sym fo nya p p;
}
 Q :

Er ase Bl a nk Jso n Loop

I  h a ve a r a ils bac k e nd  tha t recieves JSON t h at (when parsed)looksli k e: [ 
  {" kind"=>"Ma ga zine" ,  "price " => [ " $ 20. 9 9"]},
   {"ki nd"=>"Book" ,  "p rice"= >" "," title" =>""} 
] 
Ba sically wha t Iwant to d o is f o r eachk ind ofproduc t ( e.g . Ma g az in e o rb ook ) ,ifa llother at tr ib utesexce p t f or t hekind  keyare blank, th endon' t  sa ve th at ar rayke y/val ue. So  in m yexample, Magazi ne w ould stay  in  t hear ray,b ut the  Bo okkind wo uld bed ele te d ( be cause both attribu te s pr ice andtitlea re  b l ank.
I k no w I  cou l d  loop  thr o ug h with s omethi n gli ke (lis tis the  p ars edJSONb efor e):
li st.eachdo |l | 
    if l["kin d "] == "Magazi n e"     i f l ["price"].b lank ? 
      # T H EN DE LETETH I SI TERATION
       end 
   end 
end

but this se ems very r e p e titive a nd n o tc lean. How do I  do t his better ? 

A:

Th e idi omatic w ay to dot h is would  in vol veusi n g  A rray#reject!t o  rem ov e the u nwa nted li nes .  Yo u c an  also ext ract jus tth eva lue s, re m ove thebl ank  o nes , and countthe r emai ni ng val ues...m ak i n g su re  t hat'ki nd ' isoneo f t hem...list.reje ct! {|it em |item.va lues.reject(& :b lank?).siz e< 2  && it e m ['kind'] .present?}

Notice thed ifferen cebetwe en r eject and  re ject!. ..o ne ret urns a  newha shw h ile t h e !met ho d modifies i t i n pla ce .

Q:

VPS  Routing - packets ove r 1kb timeout 

I  hav e avps ru n nin go n a D ebian (Squeeze)  which sta rt e dto play fu n ny3days ag o. I ca n acc e ss it t hrough ss h but all  c omma n d s t hat lead t o a netw ork traff i c ofm or e tha n 1 kb han g.  ie : lson a d i rec torywith a  c oupleof fi le s work b ut ls on a directory wi th man y fil eshangs. Sa meg oes  for top,  mor e, tail...  an d o f cou rse any
 add_directives that_pass request to PHP,_in this_case_it's really_simple:
location_/about/payment {
 _  auth_basic_   _  __  "secured site";
    auth_basic_user_file /var/www/my.passwd;

    root...;
 __ try_files_$uri_@symfonyapp;
}

_Q:

Erase Blank Json Loop

I have_a rails backend that recieves_JSON that_(when parsed) looks like:
[
   {"kind"=>"Magazine", "price"=>["$20.99"]},
__ {"kind"=>"Book", "price"=>"",_"title"=>""}
]

Basically what I want to do is for each_kind of product (e.g. Magazine or_book), if all_other_attributes_except for the kind_key are blank, then don't save_that array key/value. So in my_example, Magazine would stay in the array,_but the Book kind would be_deleted (because both attributes price_and title_are blank.
I know I could_loop through with_something like_(list is the_parsed JSON before):
list.each do |l|
 _  if_l["kind"] == "Magazine"
   __  if_l["price"].blank?
__ _  __ _#_THEN DELETE THIS ITERATION
  __   end
   _end
end 

but this seems_very_repetitive and not clean._How do I do this_better?

A:

The idiomatic way to do this_would involve_using Array#reject!_to remove the unwanted lines.   You can also extract_just the values, remove the blank_ones, and count the_remaining values..._making_sure that 'kind'_is_one of_them...
list.reject! {|item| item.values.reject(&:blank?).size < 2 && item['kind'].present?}

Notice_the difference_between reject and reject!... one returns_a new hash while_the!_method modifies it in place.

 Q:

VPS_Routing - packets over 1kb timeout

I_have a vps running on_a_Debian_(Squeeze) which started to play_funny 3 days ago. I can_access it through_ssh but all commands that lead to_a_network traffic of more than 1kb_hang._ie: ls on a directory with_a_couple_of files work but ls_on a directory with many files_hangs. Same goes for top, more, tail... and of_course any