Run Ruby on Rails on Mac OS X in Minutes with Locomotive

Friday, October 13th, 2006

After contemplating modifying my Mac to run Ruby on Rails I decided against any system modifications. The main reason is any documentation on the web regarding installing Rails on the Mac was a little too out dated for my liking and very little support.

So what was I to do? Well I decided that using Locomotive from http://locomotive.raaum.org/ was going to be the safest and easiest option and I wasn’t wrong. Installing Locomotive was super easy and all I needed to do was download it, mount the dmg file and drag the Locomotive Icon into my Applications folder and Bingo! Ruby on Rails is ready to go.

The only thing to keep in mind is that you need to make sure you use the open up any terminals from within the Locomotive interface which is again pretty easy to remember. Locomotive at the time of this post uses the lighttpd web server by default when starting the web server using the command ruby script/server. If you prefer you can use the Webrick webserver with Locomotive by forcing it ruby script/server webrick. Supposedly Webrick is better but I’m no expert so I’m just using Webrick for any development.

The only other thing to keep in mind with Locomotive is that if you want to do more robust database work you’ll need to have MySQL installed on the Mac as the databases shipped with Locomotive aren’t really for a production environment.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Remove Spaces from a String using PHPt.

Saturday, June 24th, 2006

This is quite a funny one for me. As you may or may not know I’m not a guru PHP developer but I do know a little from my time as a web designer/developer. Today I had to do something as simple as removing spaces from a variable string using PHP.

After a quick think about how I was going to do this I put together some code that would remove the spaces.

$mobile = ” 0400 000 000″;
//echo $mobile;
$mobile = trim($mobile);
$numcount = strlen($mobile);
//echo $numcount;
$ptr=0;

while ($i <= $numcount) { //Loop until testing of all numerals in ph no
if ($mobile{$ptr} != ” “) {
$ptr++;
}else{
$mobiletemp = substr($mobile, 0, $ptr);
echo “mobiletemp:”.$mobiletemp.”\n”;
$mobile = $mobiletemp.substr($mobile,($ptr+1),$numcount);
echo “mobile :”.$mobile;
$ptr++;
};
$i++;
}

So here I was really proud of myself for cooking up such an elaborate chunk of code that would do what I needed. During the process of writing the code I posted a question on a developer forum asking for a quick way of removing the spaces. By the time I finished my piece of code I had a response from the developer forum.

And here was their solution

$mobile = str_replace ( ‘ ‘, ”, $mobile );

That’s right. Just one line of code to do the same thing as my 18 lines of code. Same solution different method.
Hopefully someone who like me needs to know how to do this in a hurry and will find this post.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]