The Accidental Rubyist

invalid byte sequence in UTF-8

Archive for the ‘being_geeky’ Category

OSX Lion compile screen with 256 colors

leave a comment »

Terminal now supports 256 colors. But screen is not compiled with 256, so no matter what you do in the screenrc file, you won’t get 256 colors. homebrew wont install screen since OSX provides it.

This blog gives you the steps to compile, and within a minute you’ll have a 256 color screen.


Written by totalrecall

November 11, 2011 at 7:40 pm

Posted in being_geeky, Mac OS X

Tagged with ,

Command-line bug tracking

with one comment

Have been using todo.txt for a few days. However, i find i am using it more
for recording bugs. todo.txt allows me to mark a task as done but not put
a comment or status. e.g. I need to put in details of what I have done as a bug-fix.

So I just checked up the net a bit and came across a bunch of command-line bug
trackers. Need something simple and CLI.

Two nice-looking projects are: tracker and ditz (coincidentally ruby, I hope
1.9.1). ticgit also looks good, but perhaps a little more complicated than what
i want.

Let me know if you are using something nice and simple for your small projects.

OUCH ! Both are giving errors! Tried tracker in both 1.8 and 1.9. There are some dependencies not mentioned. Gives an error in active-record.

$ trac bootstrap
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1667:in `method_missing’: undefined method `acts_as_list’ for #<Class:0x17973f8> (NoMethodError)
from /opt/local/lib/ruby/gems/1.8/gems/Tracker-1.0.0/bin/../lib/comment.rb:3
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

$ ditz

/opt/local/lib/ruby1.9/gems/1.9.1/gems/ditz-0.5/lib/model-objects.rb:1:in `require’: /opt/local/lib/ruby1.9/gems/1.9.1/gems/ditz-0.5/lib/model.rb:214: multiple assignment in conditional (SyntaxError)

The person on the ditz mailing list, says he is no longer maintaining it since it never really met his needs.

The saga continues:

I install gnu gnats (sudo port install gnats), installs fine, but on executing send-pr it complains it cannot find a file pr-edit.

I install another ruby bug tracker, ticgit. Seems to be for 1.8 since I ran into a “when :” error. Fixed that but it goes on to another.

$ ti new -t ‘my new ticket’
/opt/local/lib/ruby1.9/gems/1.9.1/gems/git-1.2.5/lib/git/lib.rb:329:in `chdir’: wrong number of arguments (1 for 0) (ArgumentError)
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/git-1.2.5/lib/git/lib.rb:329:in `config_get’
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/git-1.2.5/lib/git/base.rb:135:in `config’

So no command-line bug-tracking for me, … as of now at least.

Vim + Firefox:

Written by totalrecall

November 3, 2009 at 5:46 pm

Posted in being_geeky

Fooling around with todo lists

leave a comment »

I am finally trying out something called todo.txt
and this.

todo.txt looks good, is a bash script (sed heavy), generates a simple text file, allows for setting of project name, or tags, and priorities. Just the kind of simple thing I’ve been looking for. Over the years I’ve tried out many alternatives but given up. Most of these don’t generate a text file.

1. High-priority – nice Mac app, available on the top menu
2. todo app (a Dashboard widget), available on F12
3. todo list in iGoogle (i still have tasks in it)
4. Tasks in gmail (abandoned)
5. Using alpine for tasks, send them as emails, and flag them off (abandoned)
6. Using gmail itself for tasks, labelling them. (abandoned)
7. taskpaper – a vim plugin, installed it but was not impressed
8. I just saw doneyet, but I think it expects me to download a subversion project.

Written by totalrecall

October 31, 2009 at 6:09 pm

Posted in being_geeky

Automating export of Firefox 3 bookmarks and history from command-line/cron

with 7 comments

Firefox 2 used a bookmarks.html file for bookmarks. History was in a mork file that was incomprehensible. Firefox 3 uses SQLite for both these. Export manually is simple from the Bookmarks-Organize Bookmarks menu option. This page gives us info on how to automate bookmarks export using about:config, however this export happens:

  1. only for bookmarks, not history

  2. only when Firefox is shutdown

So the only option I had was to access the database via python or ruby. Both have packages for that, the python one comes with python (no install) so i tried that and got “database locked”. Googled but no one had an answer for that.

Finally, I just copied the file (hint courtesy), places.sqlite to places1.sqlite and was able to open (pls note that FF3 is still running).

It seems I already have a program called “sqlite3” on my os x. Loading it on the backup file showed me that I had various output formats such as html, csv, list etc. I could output to a file … same stuff as any other sql client – if you’ve used mysql, you’d be very familiar.

Now automating the output of the history and bookmarks without shutting firefox, and without user intervention in any format is as simple as:

cd /Users/john/Library/Application\ Support/Firefox/Profiles/8j7l8qg8.default
cp places.sqlite places1.sqlite
sqlite3 'places1.sqlite' <<!
.dump html
.output moz_places.html
select url,title from moz_places;

This may be run as a cronjob. Be sure to change the path in the cd command to your user, and edit the dump to list or csv as required. The output would go into some work folder for other applications to access easily. The existing location has a space which can cause bash programs to gripe (wish they would make life easier for us command-line junkies).

Bookmarks are stored in the moz_bookmarks file with title but not url. To get the url you would link to moz_places with the fk field as:

select a.url, b.title from moz_places a, moz_bookmarks b where and b.title like '%zsh%';

in order to dump all rows, just give:

select a.url, b.title from moz_places a, moz_bookmarks b where;

Before processing this text you may wish to filter out pages your other apps do not need such as google searches, your own websites/blogs, pagead urls etc. Also you may want to remove duplicates with the “sort -u” command.

Hope this helps.

# join pairs of lines side-by-side (like ‘paste’)
$ cat | ruby -pe ‘$_ = $_.chomp + ” ” + gets if $. % 2’

Written by totalrecall

September 3, 2008 at 11:33 am

Posted in being_geeky, unix

Getting gmx to work without novalidate-cert

leave a comment »

This was simple (thanks to madboa)

openssl s_client -connect

This gives an output. Copy the begin certification to end certificate part and place in a file named gmx.pem.
It should look like this (lines deleted in between):


openssl x509 -in gmx.pem -hash -noout

#(this outputs: ca09c2c4)

cp gmx.pem ca09c2c4.0

#(copy the .0 file to the location pointed to by openssl version -d)
sudo cp ca09c2c4.0 /opt/local/etc/openssl/certs

# fire up alpine and send a mail using gmx, and then check .pine.debug1
alpine -d tcp,imap=4,verbose=4

#show me:
# IMAP DEBUG 10:17:32 9/2: AUTH CRAM-MD5

$ man woman

Written by totalrecall

September 2, 2008 at 10:39 am

Posted in being_geeky, unix

Getting postfix to use gmail as relay host

with 2 comments

Postfix seemingly comes with Mac OS X Leopard, ready to run out of the box. I have a laptop, and am not hosting a mail server. I have a dynamic IP which means gmail won’t accept my mails.
So “ditch postfix” is the first thought. I did, and wrote my own python script to replace mail/mailx for sending through multiple accounts.

However, most programs do still go thru postfix (even if I stop it). Tried mpack yesterday to send attachments, and that too bombed on postfix. The tutorials (on the net) to use postfix with gmail as a relay host (i.e., as your smtp provider/sender go into pages of installs.

To cut a long story short, I stumbled upon this tutorial while looking for something else. Within a few minutes, I had mails going thru my gmail account, using both mailx and mpack. Whee! And thanks, Paul for the excellent article.

[Edited in Vim using HTML.vim]

Written by totalrecall

August 23, 2008 at 11:43 am

Posted in being_geeky, unix

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