The Accidental Rubyist

invalid byte sequence in UTF-8

Archive for the ‘life’ Category

Ruby versus Python versus …

with one comment

It’s been some years since I got off the Java bandwagon. I spent many years on it. and after getting off, it feels like I was in a concentration camp for many years. Strangely, I loved it then. But the freedom from drudgery, great to begin wit,h has left me hanging in mid-air for these four years.

Four years after being seduced by Ruby, I find it is still “getting there”. Many many things are still not present in Ruby, and the status is still the same. I tried Python back then and left it since the syntax seemed awful – all the “self” stuff, no private members — I had had enough of ugly code in Java to like the double underscores, and then the indentation is the block thing.

However, even in 2004. python already implemented a whole lotta stuff. Ruby is fine but not for corporate use, or if you have work to get done with deadlines. I cannot discover in the middle of a program that something has not been implemented in Ruby although there are clearly some classes and methods in the API. I can;t suddenly find that SMTP auth or Unicode etc is not there, or async io, and 4 years later the position on most things is the same. I goto ncurses and I am not so sure – python gives me more confidence. I look at GUI toolkits, wxRuby is almost there, but the developer doesn’t have time yet. Use FxRuby for the moment, and WHEN wxRuby is ready, migrate to that.

That was the great thing about Java. Vendor adoption (due to overhype) was great. There was just Swing, just jdbc, and all efforts were put into one thing to get it to work. No scratching your head to figure out what to use. So today, once again I am wondering whether I should just cut the Ruby hype crap and go to Python. Everything works. Everything is there.

I did find some funny things, though. Lists dont have a join method! You would say “,”.join(list) rather than list.join(“,”). There are many things that are strange in python and ruby coming from Java. I love many ruby features (block_given?) — wow !!! I hope python has all that.

Or maybe I will work on both, and keep getting confused while mangling data structures.

For web, I am thinking it is best to just do something called php. Dump your code on any server and it will work. Add to that most of the apps in high usage including wordpress, wikipedia, phpBB and many many bloggers, CMS’s etc are all in PHP. I can pick some open source software and build over that. Or use some framework.

Youtube and google seem to use python. Python never got the huge hype that ROR got, but still everything already works there. I just wrote an interesting command line app in ruby. I would like to put that up on some site. The only choices I can think of are javascript and php. Both of them I don’t know. Perhaps, i will rewrite it in php and put it up for the public to use. More on that later. I need to see how to upload files onto this blog along with a post, preferably. I hate posting them elsewhere and then linking back here.

Written by totalrecall

August 22, 2008 at 11:20 am

Posted in being_geeky, life, php, python, ruby

Tagged with

Really getting started with the New Blogger Beta using Java

with 2 comments

So yesterday I found that mtsend.py does not publish with Googles New Blogger. Why I need that facility is not that ECTO has anything lacking, but I DO have some diaries to load which have several hundred pages.

I have uploaded them as bare HTML’s through FTP, but would like to publish them on Blogger. So I needed a command line tool for that.

And so i went to Blogger Data API Developer’s Guide. The Java client was not downloading despite many attempts, and i wanted to avoid the blessed thing, anyway. They have some suggestions for doing it directly through HTTP POSTS and i really really struggled for hours with that with NO idea about these ways. I used CURL for that.

I managed to get authorized, and get an AUTH ID back, but when i would try to post nothing would happen. I closed shop at 3 am. Today morning i got the Java client downloaded but I don’t think they have any programs you can just start using straight off the bat.

So finally by evening, i have a bunch of Java programs ready to:


  • Get a listing of blogs given a user and password

  • To get a Feed of a blog given the Blog URL

  • To post to a blog either a file, or data from the command line

  • To update an entry given an EDIT URL and a file or data on command line

  • To delete an entry given an EDIT URL


The post program sends only one post, but it is written such that the class can be instantiated once by another program, and then many entries sent in a loop. I will come around to that soon, because authentication is quite slow, thus calling the POST program in a loop for a large number of iterations can be painfully slow.

Unlike WP which uses a serial number starting from 1 for each post, Blogger uses the Edit-Link or Edit URL which is not so friendly.

The command to post looks like this:

 java BloggerPost -U=johndoe@gmail.com -P=john341
-b="http://i-love-ruby.blogspot.com/feeds/posts/default"
-t='I really do!'
-f=test.html

The output of commands is in the same format as Movable Type/WP requires, so one should be able to with ease, push these posts to WP. I will soon write it the other way, so Java reads a MT format and posts to the New Blogger.

Yes, i could read from a config file, but each task in Java is so painful. In ruby, i would have slurped up the file in a mo using YAML, but I don’t want to have users download JYAML for just reading a user and pass up.

I shall now get back to working with curl. If i am able to get something done, I may continue with that and abandon the Java work. If i still fail, I will work more on the Java programs.

Written by totalrecall

March 4, 2007 at 3:24 am

Posted in life

Using HTML/XHTML Editing in Vim

leave a comment »

This is just SOOOOO mind-blowing. How could anyone edit HTML in anything other than VIM once they get their hands around this … HTML.vim.

One quick glance at the above document will convince you that Vim IS the text-editor to use for HTML’ing.

while (<>) {

// OOOOH ! see how they convert characters like \ to their entity equivalents by just typing ;& over the character. No having to hunt up HTML docs to figure out.

This is sooo coool kewl. And now to try out previewing this in Firefox!
Well, all i have to do is: “!open %” from within, Z’all.

One small tip for Vim newbies. In order to visually mark out a word prior to bold-facing it or running any other formatting command on it, one need not use the mouse or arrow keys to get the whole word selected. “viw” is enough. — “v” for visual mode, “iw” for internal word”. Cooler, any day, than double-clicking! The two words “any day” were bolded not through mouse or arrow key jugglery, but the very predictable and easy “v” followed by “e” meaning end of next word.

This is so @#$% easy, no more selecting words clumsily with a mouse and then searching through some menu to get formatting commands. How painful and “last century” that was!

Now let’s post this winner with a “#mtn” !

[Update: No more putting P
tags, boys, WP is adding BR and P’s all over and creating an ocean of whitespace in between paras.]

Now let’s update this champ with a “#mte” !

Written by totalrecall

March 2, 2007 at 7:43 pm

Posted in life, vim

testing vim macros with blogger

leave a comment »

gentlemen. Now is the time to rise, er raise your mineral water glasses. We can finally breathe !!!

We can finally edit our blogs in Vim, and publish them from within Vim at a keystroke. What is more we can write scripts in other languages and easily interface them with Vim. What is more, content written in Vim can then be processed by a processor such as Textile or Markdown, Maruku etc before sending off to the server!

The possibilities are endless.

Let us rejoice. We are free from the tyranny of things non-vim.

Written by totalrecall

March 2, 2007 at 5:42 pm

Posted in life, vim

testing mtsend.py -1

with one comment

This is test of mtsend.py. it allows me to send in some text formatted in vim. But i don’t know whether it handles unicode data. Because I got an error when I tried to retrieve an earlier post:

Error: 'ascii' codec can't encode character you'\u2014' in
position 72: ordinal not in range(128)

BTW, the AUTHOR field is not allowed. You will have to remove it too.

I just found an excellent article on how to use mtsend.py from within vim.
Its from Brad the Mad and i am editing the last post from within Vim.

[Update: One has to add “STATUS: publish” in the header, else the posts are going as drafts.]

Written by totalrecall

March 2, 2007 at 2:50 pm

Posted in life

testing mtsend.py

leave a comment »

This is the body of the post. Let us hope it works out well.

This means i cannot really plug in an html file directly. my html code in here could confuse the program.

Read the rest of this entry »

Written by totalrecall

March 2, 2007 at 2:01 pm

Posted in life, ruby

Interesting Stuff

leave a comment »

Finished The Northern Lights by Phillip Pullman at 3am — enjoyed thoroughly. Also, found some great stuff last night:

  • Maruku — ruby implementation of multi-markdown which is very powerful
  • Multimarkdown — quite unbelievable!
  • php Markdown Extra — php port of Multimarkdown
  • rb-appscript — psst, here’s a secret. I was never smart enough to learn Apple Script, this is praps a way of avoiding it altogether!
  • I did read of SuperRedCloth, but I am quite tired of Textile, after liking it a lot initially. It never behaved properly, always left a few “bq.” and “h2.” markers here and there, but was undoubtedly powerful.

I guess now i should take out The Silmarillion that I got as a gift on my 12th (I think) and still not read.

Written by totalrecall

March 2, 2007 at 12:57 pm

Posted in life, ruby