A fusion of technology, music, and geekyness.
Currently Browsing: Ruby

Server Update: Migration to Debian, Polyglot Projects, and More!

I am proud to announce that TechnoGeeks now has it’s own server in Atlanta, GA! I have officially migrated from Ubuntu to Debian in the process. I have finally scrubbed Ubuntu from my life for good!

Operating Systems of Choice
Server: Debian Squeeze
Desktop: Arch Linux
Phone: Android

I am starting to nerd out a lot more lately and will expand TechnoGeeks to be able to magically host several projects of mine. This includes web applications written in PHP, Ruby, and Lua! I started playing around with some of the Kepler Project frameworks (WSAPI, Xavante, and Orbit) and have a fully functioning Code Snippet library called Snippy. Orbit is ULTRA FAST but the documentation and code maintenance is VERY POOR. I really hope these guys clean things up as they have something really nice going here. More updates soon!

Update 12/5/2011:
I have several new projects and services that are now up!


Startup Script for Rails with WEBrick

I finally started playing with rails again. I decided to play around and start the basics of a billing application. I was initially debating web app versus a desktop app (rails vs ruby-gtk). I wanted a reason to finally start using rails so I decided to make it a web app. I then realized I may be able to simulate a desktop app with rails. I pulled in the base ruby packages, manually compiled RubyGems and installed necessary gems, and decided to script a startup routine so I could create a launcher on my desktop. This solution is far from perfect but it manages to fulfill my needs. My “desktop rails app” uses the built in standalone webserver WEBrick and sqlite3 for its backend.

#!/bin/bash
cd /home/jesse/rails/billing

if [ ! -f tmp/pids/server.pid ]; then
	script/server -d
fi

while [ `netstat -tan | grep 0.0.0.0:3000 | wc -l` != 1 ]; do
	echo "Server not started yet..."
	sleep 1
done

google-chrome http://localhost:3000/customers &
tail -f log/development.log

# Server can be killed with:
# kill -INT `cat tmp/pids/server.pid`

I then created a launcher simliar to this:

launcher

When I double click on the icon the first time it pauses for about 5-6 seconds while WEBrick initializes and binds to port 3000. As soon as it detects the webserver listening, I launch google-chrome to the default view. Each time I click the icon there after, the webserver is already running so the google-chrome tab kicks off instantly.


Integrating Ruby On Rails with Apache2 in Ubuntu 9.10

This is a quick and dirty walkthrough on how to integrate Rails with Apache2 in Ubuntu via Phusion Passenger. This guide provides setup instructions for a solution that includes:

  • Apache2
  • MySQL 5
  • Phusion Passenger
  • Ruby 1.8.7
  • RubyGems + gems

Install All Required Packages from Apt

sudo apt-get install apache2 ruby irb ruby1.8-dev rdoc build-essential libopenssl-ruby apache2-prefork-dev libapr1-dev libaprutil1-dev mysql-server libmysql-ruby libmysqlclient-dev

Install RubyGems

wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz
tar xvzf rubygems-1.3.6.tgz
cd rubygems-1.3.6.tgz
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Install Required Gems

sudo gem install rails passenger mysql

Compile Passenger Apache2 Module

sudo /usr/bin/passenger-install-apache2-module

Configure Apache2

sudo vim /etc/apache2/mods-enabled/phusion.load

Add the following:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby1.8
RailsEnv development

Setup Test Virtual Host

sudo rm /etc/apache2/sites-enabled/000-default
sudo vim /etc/apache2/sites-enabled/railstest

Add the following:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/testapp/public
</VirtualHost>

Restart Apache2

sudo /etc/init.d/apache2 restart

Setup Default MySQL Database

mysqladmin create testapp_development -u root -p

Setup Test Rails Application

cd /var/www
sudo rm index.html
rails testapp -d mysql
cd testapp
sudo vim config/database.yml

Put in your root MySQL username and password.

Test!

  1. Open browser: http://localhost
  2. Click link: About your application’s environment

If you see something like the following then you were successful!

rails_welcome


Goodbye CakePHP

It’s been a long journey and it has finally come to an end. Due to professional changes in my life, it is time that I stop using a PHP based MVC framework for web applications. Where will I go, you ask? Its simple – Ruby on Rails! While the aim of this post is to not convert people who use CakePHP to start using something else, I do plan on elaborating some of my reasonings for this switch.

1. My New Job
It cannot make much more sense than this. I recently got a new job (started Feb 1st). The place I work is a pure ruby shop and support several financial based web applications. I had 10 days to learn the syntax/basics of Ruby and loved every minute of it. I was ready for something new and fresh in my life.

2. Maturity
Rails was first! As a result, the project has matured more and seems to have a lot more support.

3. Package / Plugin management
Ruby has RubyGems, which is amazing. CakePHP just released something to handle plugins, but I have a feeling it is not a full package manager (think apt!).

4. Other Little Differences
Several small differences make it a better choice. I found a recent presentation that quickly explains a few of them.

That being said, PHP with CakePHP and Ruby with Rails both have their pros and cons. Each framework will always have its place in my heart. Hopefully I will have time soon to setup a rails environment and start pushing through some personal projects! Until then, I will continue gaining experience at work whilst I triage the problems that I was hired to fix :)


Powered by Wordpress | Designed by Elegant Themes