2.0!
Posted by Ryan Baxter Sun, 21 Sep 2008 19:05:00 GMT
Carleigh Jane Baxter was born on September 16th, 2008 at 1:02 AM. She weighs 8 pounds 6 ounces and is 21.5 inches long. Mommy and I are very proud. We love you Carleigh!
- Meta 4 comments, permalink, rss, atom
Installing Ruby 1.8 and 1.9 on Ubuntu from Source
Posted by Ryan Baxter Sun, 14 Sep 2008 20:30:00 GMT
I’ve begun testing my fractal library with the latest source code from the Ruby 1.9 trunk. Since 1.9 is a development release and I still need 1.8 for my Rails applications, I’ve checked out both versions and configured them to run side-by-side on Ubuntu, Hardy Heron.
Before you begin, make sure you have the autoconf, build-essential, and subversion packages installed.
It may also be a good idea to include the Ruby1.8 and Ruby1.9 build dependencies from Ubuntu’s package repository. This could prevent some headaches later on.
$ sudo apt-get build-dep ruby1.8 ruby1.9Create a directory for the Ruby source code.
$ mkdir /home/ryan/source
$ cd /home/ryan/sourceCheck out the code from the 1.8 branch. Since this branch includes patches, you can always update your source and recompile when new patches are released.
$ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 ruby1.8Next, create a configuration, configure, and compile.
$ cd ruby1.8
$ autoconf
$ ./configure --prefix=/opt/ruby1.8 --program-suffix=1.8
$ sudo make
$ sudo make installFinally, link your new binaries to the /usr/local/bin directory.
$ sudo ln -s /opt/ruby1.8/bin/* /usr/local/binTyping ruby1.8 -v in a new console should yield something similar to the following:
$ ruby1.8 -v
ruby 1.8.7 (2008-09-15 revision 19348) [i686-linux]One of the best parts of Ruby is Rubygems! Download and install it.
$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
$ tar -xvzf rubygems-1.2.0.tgz
$ cd rubygems-1.2.0
$ sudo ruby1.8 setup.rb
$ sudo ln -s /opt/ruby1.8/bin/gem1.8 /usr/local/binThe current source for Ruby 1.9 requires version 1.8 to compile, but if you’ve followed my directions up to this point you should be ready to download and compile the latest Ruby 1.9 source code.
Go back to your source directory and check out the latest code from the 1.9 trunk.
$ cd /home/ryan/source
$ svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby1.9
$ cd ruby1.9This time use the –with-baseruby switch when configuring. Set this option to the new Ruby 1.8 binary and then compile.
$ autoconf
$ ./configure --with-baseruby=/usr/local/bin/ruby1.8 --prefix=/opt/ruby1.9 --program-suffix=1.9
$ sudo make
$ sudo make installFinish by linking your new Ruby 1.9 binaries to /usr/local/bin.
$ sudo ln -s /opt/ruby1.9/bin/* /usr/local/binTyping ruby1.9 -v in your console should yield something similar to the following:
$ ruby1.9 -v
ruby 1.9.0 (2008-09-15 revision 19351) [i686-linux]Ruby 1.9 includes Rubygems! We’re done!
Since the binaries we’ve created have been suffixed with either 1.8 or 1.9, you must remember to execute them with their proper name ie (gem1.8, gem1.9, ruby1.8, ri1.9).
I’ve written these instructions from memory so if you have any problems, please post them and I’ll try to help out as best I can. Please be warned, however, that not all code written for Ruby 1.8 will work in 1.9.
- Posted in Code Snippets
- Meta 5 comments, permalink, rss, atom
Yet Another Join Method
Posted by Ryan Baxter Fri, 12 Sep 2008 21:27:00 GMT
The .NET String type has a Join method, but in my latest ASP.NET project I had the need for joining String array elements with additional prefix and suffix values. The method below delimits array elements with the provided separator and concatenates the elements with the prefix and suffix string parameters.
I’ve found this particularly handy when creating SQL statements that require the IN keyword.
string[] names = { "Bobby", "Suzy" };
sql += "WHERE People.FirstName IN (" + Utility.Join(",", names, "'", "'") + ")";Add this method to your utility class or extended String type.
public static string Join(string separator, string[] value, string
prefix, string suffix)
{
string toReturn = String.Empty;
int i;
for (i = 0; i < value.Length; i++)
{
if (i != value.Length - 1)
toReturn += prefix + value[i] + suffix + separator;
else
toReturn += prefix + value[i] + suffix;
}
return toReturn;
}- Posted in Code Snippets
- Meta 1 comment, permalink, rss, atom

