Hacker News new | past | comments | ask | show | jobs | submit login
Python to Shell to Ruby (extracheese.org)
19 points by kroger on July 1, 2010 | hide | past | favorite | 12 comments



Goes to show you how versatile modern programming languages are. I'm just starting to look at Python for a massive GREP-ing project (searching through millions of server log entries looking for some signs of suspicious activity) and I'm already impressed with the crafstmanship that went into creating it.


I enjoyed that. One can learn much from watching good developers work - even when solving mundane problems. While I've watched many 'professional'-grade casts (e.g. peepcode) - I find it curious that there aren't more of this type of 'unpolished' casts.


I agree. You may also like this screencast:

http://news.ycombinator.com/item?id=977358


Why hack around this when you can use JSON?


I don't think that Google Reader can export as JSON... ?


I often use vim for your python step. A sequence of 3 commands to convert opml to a file with feed urls, one on a line.

  :%!grep xmlUrl
  :%s/.*xmlUrl="//
  :%s/".*//
Edit: it relies on idiosyncracies about how google reader formats OPML, though.


I considered using Vim at the time. The nice thing about doing it all on the command line is that it's repeatable and persistent. I have a huge shell history, and that command will now be in my history for months. I rely so heavily on my history that I'll often remember a related command from a month ago, find it, then modify it for my current use. :)


:) Yes I can relate. I started saving my shell logs in 2006 and one of my most commonly used commands is cmd_grep.

I'm now watching http://blog.extracheese.org/2010/04/a-raw-view-into-my-unix-.... I've ended up constructing my own vocabulary (column, freq, etc.) for most common uses of perl/awk in the commandline. http://akkartik.name/bash.html


No, but Python can.


JSON syntax is Python/Ruby primitive syntax for lists and strings (although the reverse isn't quite true). Why add a library import and additional code on each side just to emit and consume what is effectively the same data? :)


Because it's a standard and not a hack, because you wont have to do workarounds like utf8 encoding unicode objects, and because it's also easy.


This is my personal list of RSS feeds, which I've been curating for many years, so I knew exactly what data was coming. It was a one-time hack: it got my RSS feed list into the database, and was never excuted again. It was also only for local testing purposes.

I think that it would be pretty crazy to import simplejson on the Python side, write extra code to dump the data to JSON, look up how to do it in Ruby (because I don't know off the top of my head), and add the code to load it from JSON. That effort would not change the outcome by a single bit. For other theoretical data sets, it would, but this is not other data sets.

If this code were ever going to be used again, sure, I'd transfer it in a safe way. But this is the equivalent of `grep`ing and `cut`ing at the Unix shell – the goal is to get data from point A to point B, never to be revisited. I reject the idea that, in this particular case, extra effort to serialize and deserialize JSON data is superior to adding five characters of str().




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: