Ruby

God can now telnet into your box

Feels good to start programming again. Even better writing patches for free software. Just finished adding telnet support for God. Now you can have god telnet to your server issue some commands and verify the output. The code is still pretty cruddy. :(

Scaling up with Rails and EC2

A challenge I faced recently was "scaling up on demand" (without manual intervention). EC2 was the my platform of choice because I could write a small script to manage all my machines. EC2 being Xen based also allowed me to create custom images of my application servers.

  1. Hook into the load balancer's health monitor
  2. If the load goes over 70% launch a new ec2 instance
  3. If the load goes under 50% remove an instance

Example:

  • @ 7am - 2 servers
  • @ 1pm - 4 servers
  • @ 6 pm - 3 servers
  • @ 9 pm - 2 servers

I have a base of 2 machines, and no real limit set to the maximum number of ec2 machines that can launched. The script is set to send me a mail every time a new machine is launched or terminated.

Now I am trying to automate creation of MySQL Slaves

Ubuntu Ruby

My powerbook recently crapped out. Time to bring out the good ol' think pad. Got hold of my ubuntu disk and started installing.

Just found this meta package.


apt-get install ruby-full

Yay!

Change.org goes 2.0!

After months of hard work and sleepless nights, we finally launched the second version of change.org. I generally try to talk about cool things I am working on; but this was not possible with change.org because there was no time to waste. Every minute counted.

Today we launched the second release of the site, which not only helps you support changes you would like to see in the world. But also find politicians that are willing to support your cause. We spent hours discussing if change politics should be a site of its own, because some of us did not support the idea diverting focus away from the non profits ( at some point I belonged to this camp ) but after careful evaluation we managed to find our own middle path.

Ruby the new PHP

Once upon a time (way back in 2002) people laughed at me when I said I only know Ruby or asked me what is Ruby? Hence I learnt PHP. Now Ruby is the new PHP just like how white is the new black, and tags the new taxonomy.

Now I feel sad for all the time I wasted learning PHP. Only good thing with PHP is I get to mess around with Drupal. Just crossing my fingers that IO or Python does not turn out to be the new Ruby... at least for a few years more.

Mood: Depressed..

Emacs support for Ruby and Rails

This is a update to my previous blog post. All credits to the authors and contributors. I just host these files.

Installation for ruby support and ruby electric. Add the following lines to your .emacs file


(require 'ruby-mode)
(require 'ruby-electric)

Installation for ruby on rails support. Add the following lines to your .emacs file


(defun try-complete-abbrev (old)
(if (expand-abbrev) t nil))
(setq hippie-expand-try-functions-list
'(try-complete-abbrev
try-complete-file-name
try-expand-dabbrev))

(require 'rails)

Global Drum and Bass Port to Rails

David "DJ Cookie" Killingsworth and I have been working on this side project called Global Drum and Bass, we are near completion of the project, we have pratically everything we need lined up for this.

We are going to replace Xoop with Ruby on Rails. I have already touch my first internal Beta. Just waiting for a good design before releaseing a Public Beta (Web 2.0 Required from what I understand).

As with all our projects, this is going to be free of charge for everyone.

Multilingual Rails Tutorial

Some of you have already integrated my patch, some of you have already figured out how to use it without any help ( that was the initial plan after all ). As for those who don't, here goes.

_I did promise earlier that the support will be modular just like our views, but since the system loads all the languages into memory before serving request, I decided to drop it for now._

*Step 1. Locale directory*
All the language files are supposed to be stored here.

# mkdir app/locale/

*Step 2. Create the lyml file*
This is where you store all your language strings, it is recommended you use the iso standard eg. en-gb.lyml, en-us.lyml etc...

*Step 3. Add strings*
You now need to add all the strings you are going to use in your application, since this is yaml you dont need to be a genius to add stuff, and remember to use a editor that supports utf like emacs or vi.

file: en-gb.lyml

en-gb:
hello: Hello-gb
world: World-gb

file: en-us.lyml

en-us:
hello: Hello-us
world: World-us

*Step 4. Setting the default language*
The system stores the language to use in session[:language]. You now need to add some code to set a language if it has not been set, I am working on a way where you can specify your default language in environment.rb

*Step 5. Usage*
Now in your views you can simply just do a <%= t 'hello' %><%= t 'world' %> and depending on the language you have set, it will use the correct strings. You can also do a <%= t 'hello', 'en-gb' %> where it will output the hello string for en-gb even if the language environment is set to en-us


Technorati Tags:

Multilingual Web Applications

Not everyone speaks the same language, Google and Yahoo have lead the way to multilingual web applications. Rails promotes Web 2.0, and I think accessing your favorite application in your own language is a must for Web 2.0. I spent some time yesterday trying out the different ways of making my application support multiple languages, most of them were too complex for a Rails newbie to install and use. Rails has always been all about “out of the box” features, so I decided to sit and code up support for multilingual Rails.

Syndicate content