Sunday, February 25, 2007

7 Habits For Effective Text Editing 2.0

I've been watching videos on Google lately. Here's one that I really enjoyed and it's inspiring me to do a talk at my work on vim. It seems like every vim hacker has their own bag of tricks that help their productivity and cross-pollination is a good thing.

Seriously, find time to watch a little bit of this video. Actually, more importantly--find time to learn more about your text editor and then hack! This video encouraged me to find ways to leverage my vim knowledge in other areas. I've finally started using mutt for email (for some reason I thought it was going to be hard to get working and had been putting it off for a long time).

Sunday, February 18, 2007

Stickittodamanitis

I stumbled across this program last night and figured I hack it out for those of us who don't met the installation requirements. It's been something that has annoyed me about every cell phone carrier I've ever had--not having an easy way to know my monthly usage. Actually, I can't complain too much, I remember when I had SunCom years ago and I couldn't even get that information from a website. The truth is Verizon's site isn't that much fun to use and I never check it more than once a month. Enter saldo.rb:

(I don't have enscript configured on this machine, please forgive me for how blogger displays this)

#!/usr/bin/env ruby
require 'rubygems'
require 'curb'
require 'hpricot'

username = Curl::PostField.content('IDToken1', ARGV[0])
password = Curl::PostField.content('IDToken2', ARGV[1])
realm = Curl::PostField.content('realm', 'vzw')
charset = Curl::PostField.content('gx_charset', 'UTF-8')

c = Curl::Easy.new
c.url = "https://login.verizonwireless.com:443/amserver/UI/Login"
c.enable_cookies = true
c.http_post(username, password, realm, charset)

c.url = "https://ebillpay.verizonwireless.com/vzw/overview/unbilled-usage-minutes.do"
c.perform
Hpricot(c.body_str).search("//table[@class='modStdTbl']").each do |table|
(table/"//tr").each do |row|
#I couldn't get the CGI library to unescape ;
(row/"//td").each {|c| print c.to_plain_text.gsub(/;? /, "") + "\t\t"}
puts
end
end

Saldo is a term used in Spain to refer the the remaining balance on your phone. Since most people over tend to use the 'pay as you go' plan it's important to always know how much you have left. All the providers I know of in Europe make that fairly painless to find out from your phone. Until I get that from Verizon I'm going to be running this as a cronjob and mailing it out to myself and my wife.

I'm not sure how watchmycell is implemented but my guess is it's something similar. I couldn't find any sort of web services provided by Verizon so I had to use curb and hpricot.

Tags

my google reader feed