Code In Design

Apr 30

My Ruby on Rails on Windows setup

I am not a Windows fanboy but sometime I have to use it. Here is my current Ruby on Rails environment setup on Windows 7.

Since I dealing with console (Command Prompt) a lot, so before I setup Ruby and Rails, I install these 2 nifty tools first.

Console

Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles.

Get it here.

ANSICON

I like colored console output mainly because I often dealing with log files. ANSICON is a tool that provide those colors.

Here is how I install it

The last command you run will install ansicon permanently. To uninstall ansicon, simply close any programs that currently using it and run ansicon -u from the Command Prompt.

Now the Ruby part. In summary, I install the 1.8.7 version first, then pik the Ruby version manager and then the Ruby Development Kit.

Ruby 1.8.7

Download and run rubyinstaller-1.8.7-p334.exe, install Ruby in their default folder C:\Ruby187 and don’t forget to check ‘Add Ruby executables to your PATH’.

Open up a Console and execute

ruby -v 

and you should get

ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]

pik

First, you want to update your gem

gem update --system

I usually don’t need ri and rdoc from the installed gems so I disabled it by default. Create a file named .gemrc in your home directory

C:\Users\YourUserName

with the following content

gem: --no-ri --no-rdoc

Now install pik

gem install pik

Read the rest of the installation manual here

Development Kit

Installing native gem has never been easy for Windows people, until DevKit came in into the scene. Follow the detailed instruction here.

Download DevKit and extract to C:\DevKit then from a Console

cd C:\DevKit
ruby dk.rb init

Test your installation by installing rdiscount gem

gem install rdiscount --platform=ruby

rdiscount should installed correctly

ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html

you should see

<p><strong>Hello RubyInstaller</strong></p>    

XAMPP (for the MySQL)

No suprise that you will also need MySQL on your Windows setup. I use XAMPP. To connect your Rails app to MySQL you will need mysql2 gem. This is how to install mysql2 on Windows 7 using XAMPP

gem install mysql2 -- --with-mysql-include=C:\xampp\mysql\include --with-mysql-lib=C:\xampp\mysql\lib\opt

Done!

Now you are ready to build the next big thing in web application industry using Rails right from your Windows box.

Dec 10

Link dump for November 2010

A bit late though..here we go.

being agile: Creating and publishing your first ruby gem

Don’t Know Metaprogramming In Ruby?

jQuery 1.4.3 Offline Learning Kit - jQuery 1.4.3 Offline Learning Kit

Securing your SSH Server | Rackspace Cloud Computing & Hosting

Focus: My new book on simplicity in the age of distractions | zen habits

8 Ways to Speed Up the Performance of CakePHP Apps | PseudoCoder.com

Ruby on Rails web development services: Applicake

Howto: SSH into VirtualBox 3 Linux Guests by Stuart Colville

Multiple params in find query - RefactorMyCode.com

Nov 15

How to undo a push?

I wan to undo my last commit and push in branch master

$ git reset --hard HEAD^
HEAD is now at 539b80a CommitMessageGoesHere
$ git push -f origin 539b80a:master

Nov 13

Simple web application admin template -

2 columns

Nov 02

Link dump for October 2010

Your Pages Will Load Faster with Rails! | Engine Yard Ruby on Rails Blog

How to hire a programmer when you’re not a programmer - (37signals)

How To Score Your Rails App’s Complexity Before Refactoring

You’re Cuking It Wrong – Elabs

Yet another Rails security checklist

:focus

Inline Code Finder - Robert’s talk

The First Step of Refactoring a Rails Application

peritor’s webistrano at master - GitHub

Linode - StackScripts - Custom recipes for your Linode StackScripts Need a way to quickly get a LAMP stack up and running that’s automatically tuned, tweaked and optimized for you? Ever wished there was a way to deploy a Wordpress stack that worked right out of the box? How about an easy way to deploy a cluster of identically configured Linodes?

StackScripts™ provide a flexible way to customize our distribution templates. They’re very easy to use — find a StackScript, answer its questions, and click deploy. When the deployment is first booted, the script is executed and does its thing. You can even watch its progress by viewing the console.

CollabNet Scrum and Agile Blog » A ScrumMaster’s Checklist

dcrec1’s inploy at master - GitHub - Rails deployment made easy

git undo last commit - Stack Overflow

Deploying WordPress with Capistrano using wp-cap

Here is the steps:

  1. Clone wp-cap to a directory, e.g. my-wordpress git clone git://github.com/adamhunter/wp-cap.git my-wordpress
  2. Copy your WordPress files to my-wordpress/public so you will have

    my-wordpress/
    ├── config
    └── public
        ├── wp-admin
        ├── wp-content
        └── wp-includes
    
  3. You want to point your WordPress domain to my-wordpress/public

  4. Move my-wordpress/public/wp-config-sample.php to my-wordpress/config/wp-config-sample.php

    my-wordpress/
    ├── Capfile
    ├── config
    │   ├── deploy.rb
    │   └── wp-config-sample.php
    ├── public
    │   ├── index.php
    │   ├── license.txt
    │   ├── readme.html
    │   ├── wp-activate.php
    │   ├── ...
    
  5. Now make sure your WordPress installation is good to go

  6. Push your changes in my-wordpress to your own Git repository
  7. Edit my-wordpress/config/deploy.rb to conform your production environment. You will need to set:

application: this is the name of your application and the folder it will reside in on your server domain: this is the domain of your app user: this is the user that will be used to SSH and copying your files to your server git_domain and git_user should be self explanatory db_name, db_user, db_pass, db_host and db_prfx are all pretty self explanatory too if you have ever read through wp-config-sample.php. If you haven’t, go do that right now.

  1. Run cap deploy:setup
  2. If everything is good, run cap deploy

I created an example of WordPress setup using the wp-cap deployment script here

Oct 07

How to undo a commit and redo? -

Here is how

git commit ...
$ git reset --soft HEAD^
$ edit
$ git commit -a -c ORIG_HEAD

Why aren't you using git-flow? -

Git extensions to provide high-level repository operations for Vincent Driessen’s branching model.

Oct 05

Link dump for September 2010

Creating a Rails 3 application | a step-by-step screencast

11 Undiscovered Website Ideas to Steal and Make You Rich

google-sitemap_gen | Download google-sitemap_gen software for free at SourceForge.net

Behat - BDD in PHP - Behavior driven development for PHP

How to Code up a Web Design from PSD to HTML

Think Vitamin » 5 Advanced Photoshop Techniques for Web Designers

Think Vitamin » Advanced Photoshop Techniques for Web Designers – Part 2

Photoshop 101 – Working with Slices | Design Reviver

Best Lightweight PHP Frameworks of 2010 | Webification

Slim - a simple PHP framework

Building a Continuous Integration Server for PHP with Hudson – techPortal

Jeff’s Blog - Building a fast, lightweight REST service with Rails 3

You’re cuking it right - Here are some quick lessons in real-world Cucumber story writing.

Ben Alman » JavaScript Linkify » Examples » Linkify

How to test file uploads with Cucumber « Cássio Marques

DjangoCon 2010 Scaling Disqus

Amazon Web Services Developer Community : Tips for Securing Your EC2 Instance InfoQ: Confessions of A New Agile Developer

A List Apart: Articles: Strategic Content Management - In this article we will explore ways to apply strategic thinking to CMS selection and customization, through design.

hyphenator - Project Hosting on Google Code - automatically hyphenates texts on websites

aristus’s sweet-justice at master - GitHub - Some pithy Javascript for beautiful justified text

Take.fm | Movies BitTorrent downloads directory

htty - htty is a console application for interacting with HTTP servers

multi-mechanize - Project Hosting on Google Code

Pylot | Open Source Web Performance Tool

Medical Free/Libre and Open Source Software

Chandler Project - Welcome

Sonar - Sonar is an open platform to manage code quality

Software development magazine: programming, software testing, project management, Agile, UML

InfoQ: Should the Best Scrum Team Be Rewarded?

Oct 01

Sanitize to the rescue! -

Most of the applications we create these days usually have an admin interface where an user with necessary privileges is able to manage the application content, respecting some business rules. Thus it is required that part of this content is easily manageable, which means the user needs to be able to add some formatting to the content. For us, it usually means that the user has to input HTML tags. And it also means that the user can do things that might break our application.