Posts belonging to Category Ruby

Seconds, Minutes, Hours – Converting Time Units in Ruby

I’m sure you’ve probably seen this question in your programming classes.. I decided I wanted to play with Ruby again and was remind of this problem, so thought it might be fun as a simple exercise to do this in Ruby.
The problem is to take a long integer and convert it to hours, minutes and [...]

require: command not found in ruby

While I was getting some old Ruby code of mine out to convert ruby code to pretty HTML-formatted code suitable for blogging from Wolfman’s Howlings I got the following error:

$ ./ruby2html.rb
./ruby2html.rb: line 9: require: command not found
./ruby2html.rb: line 10: require: command not found
./ruby2html.rb: line 11: require: command not found
./ruby2html.rb: line 14: syntax error near [...]

SQLite3 and ‘No Such File to Load’ errors

While I was playing with Rails 2.1 I decided to try the SQLite3 support that comes built into OS X instead of using MySQL. Upon trying to run a migrate command via rake I was created with:

rake aborted!
no such file to load — sqlite3/database

After some digging around I found out that (for at least [...]

Starting The RDoc Server for Ruby on Rails

I don’t know why this isn’t better documented or stated anywhere so I’ll just iterate it here. If you want to peruse the documentation for Rails and your installed Gems type the following
gem server
And in your terminal prompt you should see
Starting gem server on http://localhost:8808/
And you should be set.

Zed Shaw: Rails is a Ghetto

Mongrel Developer/Creator, Zed Shaw, cut loose on the Ruby and Rails communities in a recent posting to his website. He gives some interesting insights into who the major players are, and cuts through some of the hype surrounding rails.
While caustic in his delivery, he makes excellent points about the industry in general. If you’re [...]

Building Ruby in OS X Leopard

Most people when they get into developing for Ruby on Rails on OS X probably use this handy guide to install the latest Ruby and Rails on OS X
http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx
If you build Ruby on your Leopard installation to use the latest and greatest ruby-1.8.6-p111 release following that guide you’ll probably be greeted with something like this [...]

Adding to the Ruby Library Path

My friend Lori noted a great way to Add to the Ruby Library Path. She also noted that I had no way to put comments on my blog. Users would get sent to a page telling them to log in, but I never provided the login link
Fixed — check out the “Links” section [...]

How Ruby Finds Libraries

In Ruby not library management is not always as simple as running gem install.
Some Ruby code is distributed simply as libraries. So where do you put these libraries? The clue is
in the Ruby $LOAD_PATH variable.

irb(main):001:0> puts $LOAD_PATH
/usr/local/lib/ruby/site_ruby/1.8
/usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.10.1
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/1.8
/usr/local/lib/ruby/1.8/i686-darwin8.10.1
.
=> nil
irb(main):002:0>

This tells you that you can put your library code in any of the [...]

Ruby Net::HTTP Vulnerability

I just saw on the Codegear Ruby newsgroups that a vulnerability on the net/https
library was reported. Basically the library doesn’t validate the server certificate
CN (Common Name).
You can read the details here:
http://www.isecpartners.com/advisories/2007-006-rubyssl.txt
Patches have been done for Ruby to accommodate this and you can download them from here:
http://www.ruby-lang.org/en/news/2007/10/04/net-https-vulnerability/

How to Format Ruby Code for Blogs

I saw this article on formatting ruby code for blogs. Nice article, but the code is Linux/KDE-specific. Also, OS X threw an error about the order of the require statements. Being that I use OS X (and so should you) I needed to make a couple of changes to the code that [...]

Get Adobe Flash playerPlugin by wpburn.com wordpress themes