[{"data":1,"prerenderedAt":411},["ShallowReactive",2],{"project-17755199":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":47,"post_text":49,"what":50,"said":76,"maker_in_thread":161,"shape":172,"grid":176,"attempts":374,"same_week":375,"maker_shows":43,"maker_hidden":403,"reader_version":404,"card":405},"17755199","Rb","Turns Ruby into a command line utility","title","Show HN: Rb – Turns Ruby into a command line utility","https:\u002F\u002Fgithub.com\u002Fthisredone\u002Frb","github.com","redka",1534214234,2018,232,73,140,2155,7,"notable","dev_tools","command line utility","cli",[24,25,26,27,28],"ruby","command line","text processing","stdin","one-liner","mixed",0.007,{"positive":32,"neutral":33,"mixed":34,"critical":35},8,14,2,6,30,{"idea":38,"execution":41,"docs":44,"performance":45,"design":46},{"positive":39,"critical":40},4,3,{"positive":42,"critical":43},0,1,{"positive":42,"critical":42},{"positive":42,"critical":42},{"positive":34,"critical":42},[48,40,42,40,40,40,42,40,43,43,42,42,42,42,42,40,43,40,48,42,42,42,42,48,42,43,40,43,42,42,40,48,48,42,42,42,42,40,48,40],5,null,{"problem":51,"audience":49,"pricing":49,"motivation":49,"time_to_build":49,"stack":67,"openness":74,"stage":75,"team_size":75},{"value":52,"source":53,"evidence":54},"Processing text in the terminal with Ruby one-liners is awkward","commenter",[55,59,63],{"id":56,"by":57,"text":58},"17755507","Ajedi32","Interesting, so it's reading text from STDIN into an Array, then executing its arguments as Ruby code in the context of that Array (or if you pass -l, in the context of each line…",{"id":60,"by":61,"text":62},"17755463","star-techate","Command line tools in 10 lines of ruby (using this script): ``` docker ps | rb drop 1 | rb -l split[1] docker ps -a | rb grep \u002FExited\u002F | rb -l 'split.last.ljust(20) + \" => \" +…",{"id":64,"by":65,"text":66},"17756343","tigrezno","- Reading all the lines into an array is a big error. - It's a bit unintiuitive because you don't really know what strings to escape on the bash command line. In the example,…",[68],{"value":69,"source":70,"evidence":71},"Ruby","maker",[72],{"id":73},"post","open_source","unknown",{"praise":77,"objections":90,"requests":124,"questions":132,"alternatives":137},[78],{"value":79,"source":53,"evidence":80},"Nifty and neat idea",[81,85,89],{"id":82,"by":83,"text":84},"17756701","tobyhinloopen","First I thought: This is stupid. But then I watched the examples on github and here in the comments, and I changed my mind: It's pretty neat :) I like it.",{"id":86,"by":87,"text":88},"17755540","jaequery","its a pretty nifty idea",{"id":56,"by":57,"text":58},[91,99,109],{"value":92,"source":53,"evidence":93},"Reading all input into an array hurts streaming and performance",[94,98],{"id":95,"by":96,"text":97},"17755576","pulisse","The command should process stdin in streaming fashion rather than slurping it all at once: ``` code = ARGV[0] STDIN.each_line do |l| puts l.instance_eval(code) STDOUT.flush end ```",{"id":64,"by":65,"text":66},{"value":100,"source":53,"evidence":101},"Install via curl piped to bash is a security concern",[102,106],{"id":103,"by":104,"text":105},"17759250","KeyboardFire","It makes me a little uncomfortable that they're using curl|bash for something as simple as \"put this 10-line script somewhere in your $PATH,\" especially when the script involves…",{"id":107,"by":57,"text":108},"17759533","Yeah, and it's not even getting the code from an official source; it's coming from a random bit.ly link [created by a contributor][1]. I've [submitted a PR][2] to inline the…",{"value":110,"source":53,"evidence":111},"Standard Ruby one-liners or awk\u002Fperl already do this",[112,116,120],{"id":113,"by":114,"text":115},"17755448","meow_mix","What does this have over the default ruby? cat your-file.txt | ruby -ne '$_.your_ruby_stuff' Just syntactic sugar? (it does look cleaner!)",{"id":117,"by":118,"text":119},"17755899","perlperson","``` $ docker ps | rb drop 1 | rb -l split[1] $ docker ps | perl -anE 'say $F[1] if $.>1' ``` perl solved this problem a long time ago, people",{"id":121,"by":122,"text":123},"17755953","asicsp","for your given sample, you could use awk[0] as well ``` awk 'NR>1{print $2}' ``` or ruby[1] ``` ruby -ane 'puts $F[1] if $.>1' ``` which one to use depends on lots of factor -…",[125],{"value":126,"source":53,"evidence":127},"Python equivalent of the tool",[128],{"id":129,"by":130,"text":131},"17755561","robax","I'd love this for python as I'm not a big fan of Ruby. Does such a thing exist?",[133],{"value":134,"source":53,"evidence":135},"What does this add over plain ruby -ne",[136],{"id":113,"by":114,"text":115},[138,145,150],{"value":139,"source":53,"evidence":140},"Plain ruby -ne \u002F -lane one-liners",[141,144],{"id":142,"by":61,"text":143},"17755541","``` echo hello world | ruby -pe '$_.capitalize!' printf 'hello\\nworld\\nhello\\n' | ruby -le 'puts STDIN.to_a.uniq ps | ruby -lane 'BEGIN { b = 0 }; b += $F[0].to_i; END { print…",{"id":113,"by":114,"text":115},{"value":146,"source":53,"evidence":147},"Perl and awk one-liners",[148,149],{"id":117,"by":118,"text":119},{"id":121,"by":122,"text":123},{"value":151,"source":53,"evidence":152},"Pyped and python-oneliner for Python",[153,157],{"id":154,"by":155,"text":156},"17756032","sametmax","\"pyped\" does the same for python. I though it was great, knowing python better than bash, plus it was portable to windows. But eventually I always end up using built in GNU…",{"id":158,"by":159,"text":160},"17756673","gvalkov","Several people have tried to tackle this in Python. My attempt was python-oneliner[1]. There's also a list of similar projects in the readme. [1]…",{"comments":40,"answered":43,"key":162},[163,166,169],{"id":164,"text":165},"17756370","Someone did a PR[1] with something similar. He also found a way to speed things up by creating a Proc first and feeding it to the eval instead of the string. [1]…",{"id":167,"text":168},"17760547","Thanks, merged",{"id":170,"text":171},"17756298","Exactly! It's nothing fancy but this small sugar makes Ruby more handy in those situations",{"commenters":173,"max_depth":48,"maker_replies":40,"first_comment_mins":174,"lifespan_hours":175},56,34,112,[177,179,181,185,188,191,193,197,199,201,203,206,209,211,213,215,218,219,221,225,228,231,234,237,240,243,245,248,251,255,257,259,260,264,267,269,272,275,278,280,282,285,286,289,290,291,294,298,301,304,306,309,312,314,316,319,322,324,328,330,334,337,340,343,346,349,351,354,357,361,366,369,371],[56,42,48,178,57,42],"project\u002Fpositive\u002Fidea",[142,42,40,180,61,42],"project\u002Fneutral\u002Fexecution",[182,42,42,183,184,42],"17755887","commenter\u002Fneutral\u002Fnone","dragonwriter",[186,42,42,183,187,42],"17756560","ricardobeat",[189,42,42,183,190,42],"17760398","ashelmire",[60,43,40,192,61,42],"project\u002Fneutral\u002Fnone",[194,43,40,195,196,42],"17755530","project\u002Fmixed\u002Fdocs","shawn",[198,43,42,183,61,42],"17755549",[200,43,40,180,122,42],"17755924",[95,34,40,202,96,42],"project\u002Fneutral\u002Fperformance",[204,34,42,183,205,42],"17756316","DarkWiiPlayer",[207,34,42,183,208,42],"17757289","karmakaze",[210,34,40,202,184,42],"17757580",[164,34,42,212,11,43],"project\u002Fpositive\u002Fperformance",[103,40,43,214,104,42],"project\u002Fcritical\u002Fnone",[216,40,42,183,217,42],"17759461","bdcravens",[107,40,43,214,57,42],[167,40,42,220,11,43],"maker\u002Fneutral\u002Fnone",[222,40,42,223,224,42],"17759607","other\u002Fneutral\u002Fnone","mpg515",[226,40,42,223,227,42],"17759986","kenbellows",[229,40,42,223,230,42],"17760143","kompromat",[232,39,42,223,233,42],"17756799","vinceguidry",[235,39,42,223,236,42],"17756973","bluehatbrit",[238,39,42,223,239,42],"17757222","barrkel",[241,39,42,223,242,42],"17757593","psadauskas",[244,39,42,223,233,42],"17757878",[246,39,42,223,247,42],"17790048","derefr",[249,39,40,202,250,42],"17758655","Lio",[252,39,40,253,254,42],"17760904","project\u002Fneutral\u002Fidea","somebehemoth",[256,39,42,223,247,42],"17789998",[117,48,43,258,118,42],"project\u002Fcritical\u002Fidea",[121,48,40,192,122,42],[261,48,48,262,263,42],"17756088","project\u002Fpositive\u002Fdesign","tomc1985",[265,48,42,183,266,42],"17758863","yoz-y",[268,48,42,183,263,42],"17764062",[270,48,42,183,271,42],"17756236","oblio",[273,48,42,183,274,42],"17758105","shadowphex",[276,48,42,183,277,42],"17757418","bovermyer",[279,48,42,223,104,42],"17759199",[281,48,42,223,277,42],"17766078",[283,48,42,183,284,42],"17758968","h1d",[113,35,40,253,114,42],[287,35,48,262,288,42],"17755595","hboon",[170,35,42,178,11,43],[154,18,42,223,155,42],[292,32,43,258,293,42],"17757828","code_duck",[295,296,40,192,297,42],"17755325",9,"nerdponx",[299,296,40,253,300,42],"17755387","tptacek",[302,296,42,223,303,42],"17755515","gfodor",[305,296,42,223,61,42],"17755562",[307,296,43,258,308,42],"17755796","Annatar",[310,296,42,183,311,42],"17756229","damagednoob",[313,296,42,183,205,42],"17756339",[315,296,42,223,308,42],"17764144",[317,296,42,223,318,42],"17756510","tragomaskhalos",[320,296,40,192,321,42],"17755390","simonista",[323,296,48,178,297,42],"17755457",[325,326,40,253,327,42],"17756496",10,"dorianm",[82,329,48,178,83,42],11,[331,332,40,180,333,42],"17771851",12,"binaryphile",[129,335,42,336,130,42],13,"commenter\u002Fneutral\u002Fidea",[338,335,42,183,339,42],"17755578","schappim",[341,335,42,183,342,42],"17755629","kjeetgill",[344,335,42,183,345,42],"17755880","bpanon",[347,335,42,183,348,42],"17756087","repsilat",[158,335,42,350,159,42],"other\u002Fneutral\u002Fidea",[352,335,42,350,353,42],"17757470","ericfrederich",[355,335,42,350,356,42],"17758472","dschep",[358,33,40,359,360,42],"17756650","project\u002Fmixed\u002Fdesign","kimat",[362,363,48,364,365,42],"17756122",15,"project\u002Fpositive\u002Fnone","codetheory",[367,368,48,364,365,42],"17756121",16,[86,370,48,178,87,42],17,[64,372,43,373,65,42],18,"project\u002Fcritical\u002Fexecution",[],[376,380,384,389,394,398],{"id":377,"name":378,"points":379,"category":20},"17725966","Retool",592,{"id":381,"name":382,"points":383,"category":20},"17733515","Ultralight",527,{"id":385,"name":386,"points":387,"category":388},"17744073","Didyougogo",269,"data",{"id":390,"name":391,"points":392,"category":393},"17752010","Mersey Burns",267,"infrastructure",{"id":395,"name":396,"points":397,"category":20},"17731883","graphqurl",246,{"id":399,"name":400,"points":401,"category":402},"17720786","NES Party",237,"games",false,"v2",{"id":406,"name":5,"line":6,"ai":403,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":407,"top":18,"kw":408,"maker":11,"domain":10,"tier":19,"attempts":42,"strip":409,"url":9,"mix":410,"praise":79,"objection":92,"sub":21},17755199,0.01,[24,25,26,27,28],"5303330311000003135000050131003550000353",[32,33,34,35],1794036568646]