Archive for the ‘utility’ Category

cmd line history meme

Saturday, April 19th, 2008

Aaron tagged me

brian@airstream:~$ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' |
  sort -rn | head

182 cd
141 ls
55 vim
52 ssh
44 timeclock.rb
29 ruby
28 irb
26 fr
26 cat
24 rake
  1. I’ve made a definite switch to emacs, but vim is still handy for the quick view of a file, and I start emacs in the morning via an icon, and it stays up all day - otherwise, it would be way up on the list.
  2. timeclock.rb is a handly little script to parse/format an emacs timelog file - incredibly nice way to track time on various tasks.
  3. fr is an alias for: find . -regextype posix-extended -regex ‘\”.*.r(b|html)’\” | xargs grep

Tag. You’re it :)

Automatically Delete Unwanted Cookies in Firefox

Saturday, January 26th, 2008

I prefer to not have cookies stored in my browser, but it’s impractical to not store any cookies since this would require repeatedly logging in to authenticated sites that I frequently use. A simple solution in Firefox is the following:

From the Edit menu, choose Preferences and then click the Privacy tab. You should see a dialog similar to the following one:

firefox1.png

Check the “Accept cookies from sites” checkbox. For the “Keep until” setting, select “I close Firefox”. The latter is the key - it will erase all cookies from Firefox whenever you close the program. Of course, we don’t want to erase all the cookies, so click the “Exceptions…” button on the right and you’ll see a dialog similar to the following:

firefox2.png

Just type the name of the web site you want to allow in the text box and click the “Allow” button, and Firefox will add it to the exception list so it won’t be deleted when you close Firefox. You can add a full URL such as www.MySite.com, or just the domain name MySite.com to allow cookies for any host in that domain. You an also add sites you want to disallow any cookies from by clicking the “Block” button.

I have about 30 sites that I allow Firefox to store cookies for, but this technique has helped me avoid accumulating tons of unwanted cookies in Firefox. I hope it’s helpful for you.

Use vimdiff to display subversion diffs

Tuesday, November 27th, 2007

I prefer using vimdiff or gvimdiff to view differences between files. When researching ways to allow using vimdiff to view subversion differences, I came across this article.

The bottom line is that subversion passes the two relevant arguments as the 6th and 7th arguments, so the following shell script wrapper does the trick:

#!/bin/sh
/usr/bin/gvimdiff ${6} ${7}

Save the script as gvimdiff_wrapper.sh, make it executable and accessible on your path. Then modify $HOME/.subversion/config to have the following line:

diff-cmd = gvimdiff_wrapper.sh

That will allow you to use gvimdiff to display the diff generated by svn diff my_file.txt

del.icio.us Tag Bundling

Saturday, November 3rd, 2007

I’ve written about del.icio.us several times before (use the search box to find the articles). I’ve been using the service for quite a while and still consider it to be one of the most valuable web services I use.

I just discovered the tag bundling feature from this article and tried it out. Tag bundling, as you might expect, allows you to group your tags. For example, my first bundle was “people”, so now I can see all my people tags in one group. I’ll be adding more bundles soon.

If you’re not using del.icio.us, you should really check it out. And if you, are and don’t know about tag bundling, give it a shot.

del.icio.us makes it easy to share tags - for example, here’s a link for my bookmarks on the Ruby programming language. I haven’t discovered a similar way for sharing bundles, so if you know, please leave a comment.

Social Bookmarking

Tuesday, August 7th, 2007

Here’s a video that explains why using a site such as del.icio.us can be useful. I think they may have failed to mention that you can mark bookmarks as private on del.icio.us, so it’s not necessary to expose your bookmarks to the world. However, in my case, I only mark a small fraction as private.

I’ve been using del.icio.us for quite some time. After I had been using it for a while, I realized that it had been a long time since I bookmarked something in my browser because I had developed a habit of bookmarking in del.icio.us. Most browsers force you into placing a bookmark into a hierarchical, or directory, structure, but on del.icio.us you can assign as many “tags” as you like to a particular bookmark so you can search for things more easily. del.icio.us also allows you to export your bookmarks so you aren’t at the mercy of a proprietary service.

Another thing that is handy is to subscribe to the del.icio.us feeds of your friends to be automatically notified when they bookmark something that may be of interest.

Google Reader

Monday, July 30th, 2007

I hate to promote Google given their trajectory to take over the world, but I just switched over to Google Reader for reading RSS feeds. I had accumulated over 60 RSS feeds, and it was becoming difficult for me to determine which feeds I should keep and which I should delete.

I was hoping for an automated tool that would keep track of which feeds are beneficial and Google Reader has exactly what I was looking for!

The trends feature will keep track of which articles I read from each feed and report on the total number and the percent. So, over time, I’ll be able to easily delete the feeds that have a low number and/or low percentage of read articles. If you decide to use Google Reader, you should be aware of some idiosyncrasies. When viewing in “Expanded view”, the default is to mark articles as read when you scroll past them which totally defeats the trends feature. You can turn that off in the settings.

settings | preferences | scroll tracking

I like using the “list view” instead which allows me to quickly view the titles. After I’ve read the articles I want to from a feed, I click “mark all as read” and Google Reader is smart enough to not count those in the “read” statistics.

If you’re already using a different RSS reader, you can easily import all your feeds via an opml file. I was using Liferea and had folders of feeds, and I had also renamed the feeds - the import to Google Reader kept track of all of that - nice.

Google Reader has a lot of other nice features such as keyboard shortcuts, tags, folders, etc., but once I discovered the trends feature, that was all I needed to see :)

I suppose the trends feature can be “unfair” though. Consider the following scenario:

  1. You have two feeds A and B
  2. Each day each feed publishes 10 articles
  3. The feeds overlap on 5 articles that are worth reading
  4. Feed A has 1 unique article that you read
  5. Feed B has 3 unique articles that you read

If the feeds are read in alphabetical order, then you’ll read the 5 overlapped articles from Feed A along with the 1 unique article -> total = 6, or 60%. Then you’ll read the 3 unique articles from Feed B -> total = 3, or 30%. The stats will show Feed A as being twice as valuable when clearly Feed B is more valuable. I suppose to get good stats, I should read the feeds in random order, but that seems difficult to manage.

UPDATE: ah, never mind. Simply view the folder that contains A & B and you’ll see the union of their articles in chronological order - whoever gets the overlapped story first wins :)

Adblock Plus

Monday, July 23rd, 2007

Facebook.com just ran an ad that was quite offensive to me. I should’ve taken Scott Moonen’s advice from his blog earlier, but better late than never. He has simple instructions for installing Adblock on his blog. Check it out and get rid of ads!

Half star ratings on Netflix

Wednesday, May 2nd, 2007

I noticed a friend of mine (Jordan L.) who had half-star ratings (2.5, 3.5, etc.) on Netflix. When I asked him about it, he said to just “hover over the left side of the star” to get a half-star rating. This didn’t work for me, so I thought it might be a Linux vs. Windows thing and asked another friend (Mike F.) to try it out. Same result - didn’t work in IE or Firefox on Windows. Then Mike found a JavaScript file that could be installed with greasemonkey and that worked fine for him.

I’ve yet to install greasemonkey, and I don’t like the idea of installing JavaScript on my system unless I’ve thoroughly analyzed it, so I thought of another way.

I installed wireshark on my Ubuntu Linux box and sniffed the network traffic to Netflix when I rated a movie. After some experimenting and removal of extraneous info, I came up with the following URL to rate a movie with half stars. This specific URL will rate the movie “The Incredibles” with a 4.5 star rating (probably a bad example since The Incredibles clearly deserves a 5 star rating):

http://www.netflix.com/SetRating?widgetid=M70001989&value=4.5

To rate other movies, simply replace 70001989 with the id of the movie which you can find by hovering over the movie. I believe you’ll need to be logged in to Netflix already for this to work.

Now as to why Jordan can rate half-stars without the aid of a greasemonkey script, that’s still a mystery.

Update: got an email from Jordan explaining that his Netflix pages include the following two JavaScript source files:

src=”http://www.netflix.com/layout/jscript/dom_starbar_v2.js?v=126505″
src=”http://www.netflix.com/layout/jscript/dom_starbar_halfstars.js?v=126505″

I only have the first one, and from the name of the second one, I presume that’s the one that gives him the special half star rating capability. I guess Netflix favors Jordan over me :(

Update 2: mystery solved! My curiosity got the best of me so I contacted Netflix. The rep said they’re running a test and Jordan just happened to get picked (I didn’t mention Jordan, but I suppose they looked through my ‘friend’ list)! They do that periodically to test features to see if they’ll give them to the unwashed masses. I asked if they could run the test on me, and he said it didn’t work that way :) So I guess it’s the greasemonkey script or the inconvenient URL hack for the rest of us.