The calendar is gone.
Click here to view posts


When the state runs things
I live in yet another state that controls the liquor sales. PA is the other state. After talking with a coworker about some booze they showed me the state liquor store website. Turns out that they post the prices, stock and location of all the booze they carry.

After a night of scripting I have 2 scripts. The first one finds the brands and prices. The second one finds the quantities of each brand and what store they are ... [ Read more ]

Rvm
There is a new-ish gem called rvm that allows you to manage ruby vms and gems with a few simple commands. I just used it to unscrew my dreamhost server out of config hell with gems. In less then an hour i rebuild ruby 1.8.7 and ruby 1.9.1 and install most of the gems dreamhost gives a standard account.
I suggest looking at RVM very closely. I will never run another ruby box with out it.

Current projects
I am currently working on a dashboard for my life. It will include things like the weather, news, movie release dates, OneBusAway information and other fun stuff. I am building it with rails and mongomapper. I am hoping to hang a screen on my wall and have it powered by a mac mini. Step one is to get it all working.

Other projects: Revisited IMDB and updated it to run again thanks to someone who wanted to use it. The problem with scr... [ Read more ]

Ruby and divide by zero
number = (1/0.to_f) #will not error
number = 0  unless 1<=>number # will return nil if its infinity or NaN
No more checking number.nan? || number.infinite?

Busy
Been busy. Started a new job. Gist.com Working on a few different ideas and been living. I hope to post something new soon.

Greasemonkey day1
I just got a G1 phone and I was playing around with google charts. Turns out they do QR bar codes. It turns out that the barcode scanner on my G1 reads the QR. So I made a greasemonkey script that adds the barcode to the bottom of every page. (After the body tag until I figure it out more) http://deathbyescalator.com/barcode.user.js I can now just view a site, scan it and bookmark it on my phone.

Db charsets in rails
In case you have set up your db with out utf8 support by default you can change it with active record.

tables = ActiveRecord::Base.connection.execute("show tables;")
tables.each{|table|
 create_table = ActiveRecord::Base.connection.execute("show create
table #{table};")
 unless create_table.fetch_hash["Create Table"].include?("CHARSET=utf8")
   ActiveRecord::Base.connection.execute("ALTER TABLE #{table} CONVERT TO CHARAC... <a href="/main/index/db_charsets_in_rails">[ Read more ]</a>

Rpiratebay dead
Like the real site RPirateBay is dead

Sort or in ruby
I am reading the perl cookbook and they are talking about some fun ways to use sort. I like that they are describing sort_by. I read some where that the concept was coded and posted in perl long ago. I wish they had a sort_by wrapper for it. anyway. I was reading that you can use an or statement in perl so if the first two are even sort it by a second value. I never thought of this in ruby.

array = [{:name=>"zack",:age=>30},{:name=
... [ Read more ]

Palindromes
I was asked to check a file for palindromes. Here is the code I wrote.
# returns an array of matching palindromes in the file
# the words are grouped in arrays
# 
# [['god','dog'],['act','cat']]
#
def find_palindromes(file)
  if !file || !File.exist?(file) || !File.readable?(file)
    raise "Trouble with the file"
  end
  words = File.open(file,"r").read
  words = words.split(/\s/)
  words.uniq!

  palindrome = Hash.new(Arra
... [ Read more ]