RSS  |  Archive    

Posts tagged with ruby

Curry is going to be a double edged sword.

tagged: ruby,
11:29 am, by shenie,




A while ago I posted some shell scripts to decompile java classes.

I decided to re-implement it in ruby so I can use it between my work (Windows) and home (OS X) machines.

This version does not require you to extract the class files first. You simply pass the jar file to the script and it’ll decompress and decompile it into a directory with the same name as the jar file without .jar.

4:11 pm, by shenie,




I think new version of ruby is meant to be installed with the following prefix, using 1.8.7 as an example.

/System/Library/Frameworks/Ruby.framework/Versions/1.8.7/usr

That way you can just /System/Library/Frameworks/Ruby.framework/Versions/Current to the version you want.

tagged: ruby,os x,
11:15 pm, by shenie,




As I mentioned before, I upgraded to ruby 1.8.7 and decided to use —prefix=/usr, i.e. overwriting existing ruby 1.8.6. Big mistake. After some issues I decided to roll back completely.

This is what I did (luckily I can copy the required files from my wife’s Macbook).

OS X ruby framework overview

The framework is /System/Library/Frameworks/Ruby.framework

  • /usr/lib/ruby is a softlink to osx ruby framework
  • osx ruby framework’s site_ruby is a softlinke to /Library/Ruby/Site

To fix

  • /usr/bin
  • osx ruby framework
  • /Library/Ruby/Site

Actions

Rename the following directories then copy the same directories from another OS X

  • /System/Library/Frameworks/Ruby.framework
  • /Library/Ruby/Site

Make sure the following files are links to os x ruby framework’s /usr/bin

  • /usr/bin/erb
  • /usr/bin/irb
  • /usr/bin/rdoc
  • /usr/bin/ri
  • /usr/bin/ruby
  • /usr/bin/testrb

Cleanup

Remove these backup directories afterwards (once everything is ok)

  • os x ruby framework .bak
  • /Library/Ruby/Site.bak
  • /usr/lib/ruby/site_ruby.bak
  • /usr/lib/ruby/user-gems.bak

Now

  • link /usr/lib/ruby/site_ruby to /Library/Ruby/Site
  • link /usr/lib/ruby/user-gems to /Library/Ruby/Gems

tagged: ruby,osx,
11:10 pm, by shenie,




I was in a update mood so I updated my system to use GWT 1.5.0 and ruby 1.8.7.

After updated ruby I tried to figure out how to keep the old gems. My solution was to set the following env variables (similar result could be achieved with .gemrc).

  • export GEM_HOME=/Library/Ruby/Gems/1.8
  • export GEM_PATH=/usr/lib/ruby/gems/1.8

But in the end I decided to revert back to ruby 1.8.6…. because I realised a problem that I worked around earlier is bigger than I thought. The problem was that hpricot 0.6 didn’t load properly under 1.8.7. I was too focused on understanding how OS X setup ruby framework and replicating it in 1.8.7.

All was not lost, someone has found the problem and fixed it. So once a new hpricot released then I should be able to re-apply what I learnt.

11:56 pm, by shenie,




umm… LinkedIn is looking for Rails developer~~~~

LinkedIn is keeping both its Rails & Java development as Matt suggested.

10:34 pm, by shenie,




If you liked Steve’s post then read Cedric’s comeback

tagged: java,ruby,language,
9:47 pm, by shenie,




You need:

  • jruby
  • rails (or just active record) gem
  • activerecord-jdbc-adapter

If you are using the base jdbc adapter then you need to put jdbc jar in jruby’s classpath. I just copied the jar into $JRUBY_HOME/lib

Then

  1. establish AR connection

  2. use schema dumper

e.g.

require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter  => "jdbc",
  :driver => 'com.ibm.as400.access.AS400JDBCDriver',
  :url => 'jdbc:as400://hostname',
  :username => "blah",
  :password => "secret"
)
ActiveRecord::SchemaDumper.dump

8:01 am, by shenie,




I was reading Tim’s post which reminded me that I had implemented similar things with Romey. Basically because I was running Romey on a Mac Mini at home and didn’t want to make it accessible over the internet I created another way to create transactions in Romey. It was done with a POP account at my ISP, ruby script running by cron on the Mac Mini. I stopped running the cron job since I changed ISD but having read Tim’s post I am thinking about reactivating the service again and extending it to involve Twitter as well. I already have written ruby scripts that post updates to Twitter (this and this) before. I think it’ll be cool if Romey could post to twitter when certain condition is triggered, e.g. going over budget.

After that I just need to have a mobile phone plan with internet then I can create Romey transactions anyway by sending an email and receive notifications from Romey via Twitter.

tagged: twitter,romey,ruby,
11:38 pm, by shenie,




I recently installed rb-appscript gem, which is way cool and I wanted to have a look at its implementation. So I used my ‘pushdgem’ shortcut which basically does a gem which and extract the path of the gem. But to my surprise it said ‘Can’t find rb-appscript’

I knew for a fact that the gem was installed, because TextMate’s RubyAMP (how this all started) depends on rb-appscript. But I double checked anyway running gem list rb-appscript which did contain the expected result.

hum.. I was puzzled, doesn’t matter I knew gems are installed (you can get it too via Gem.path) so I got to the rb-appscript gem in the end.

During playing with rb-appscript, a new version of rubygems was released (version 1.1.1). After I installed the update I started wondering why gem list and gem which behaved differently on the same gem.

Again my curiosity got me to have a look inside rubygems. With previously experience working with rubygems, it didn’t take long to find my way around the place. It turns out gem which command is really searching for the file that you want to require in the $LOAD_PATH. e.g. when you say require ‘hpricot’ gem which hpricot let you know exactly which file was loaded. Whereas gem list is based on the specs.

The difference means you could have a file called foobar.rb nothing to do with any gems in one of the directory in $LOAD_PATH such as /Library/Ruby/Site and run gem which foobar and it will return /Library/Ruby/Site/foobar.rb. It’s counterintuitive but I guess it is more important to know which file your program will load instead of finding out which directory the gem is installed.

5:47 am, by shenie,