What makes a really good Ruby IDE?

By kenglish

Chad Woolley over at pivotal has a blog entry about The Great Ruby IDE Smackdown of ‘09. He compares the IDE’s by doing a task that no Rails developer will ever need to do. What do we really do all day: Model, View, Controller, Test, routes, etc. The IDE should provide an easy way to switch between these. Netbeans does this. Aptana does this. RudyMine does this. They are all functional and when used properly, very effecient. What really matter to me? VI intergration. Netbeans has this with jVi. I love it.

I got a kick out of this:

“To me, the benefits of a memory- and processor-sucking IDE with tons of unnecessary, unconfigurable, resource-eating tiny-ass-fonts and chrome did not justify giving up the speed and responsiveness of a great text editor.”

Memory- and processor-sucking IDE? Is he running a 486dx? Are Macs really that slow? Dude, switch to linux! Or, here’s 10 Reasons You Should Not Switch To Linux.

Here’s another nice feature of NetBeans that your Text Editor won’t do. Notice on line 127, I have a mispelling of the word worksheet. Netbeans bolds the misspelled varialbe to tell me that I have a variable here that has never been used before. This is very helpful.

NetBeans-coolness

categoriaProgramming commentoNo Comments dataJuly 16th, 2009
Read All

Bedazzle Your Bash Prompt with Git Info (for Ubuntu 9.04)

By kenglish

This is in response to the railstip.org post about how to Bedazzle Your Bash Prompt with Git Info. If you do this in Ubuntu, it will screw up your gnome-terminal title.

This is how add the git branch to your prompt in Ubuntu 9.04. Edit /home/kenglish/.bashrc. Find the lines with PS1. Replace them with this:

function parse_git_branch {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo "("${ref#refs/heads/}")"
}
 
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] $(parse_git_branch) \$ '
    #PS1="\w \$(parse_git_branch)\$ "
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w $(parse_git_branch)\$ '
fi

categoriaLinux commentoNo Comments dataJuly 1st, 2009
Read All

Funny Sign

By kenglish

animal-image

categoriaUncategorized commentoNo Comments dataJune 24th, 2009
Read All

What a jerk!

By kenglish

This guy needs Kittens for his Tiger . If you think that’s funny, there’s something wrong with you.

categoriaUncategorized commentoNo Comments dataJune 19th, 2009
Read All

Internet Fame

By kenglish

I’ve been twittered: http://twitter.com/alohaonrails/status/2242129462

categoriaUncategorized commento1 Comment dataJune 19th, 2009
Read All

Example SQL Report with the Ruby Spreadsheet Gem

By kenglish

If you want to create a Excel reports for your users, this can be done rather easily in Ruby using the Spreadsheet Gem.

def spreadsheet_report(excel_filename, worksheet_name, 
                       column_order, result)
    book = Spreadsheet::Workbook.new
    sheet1 = book.create_worksheet :name => worksheet_name
 
    rownum = 0
    for column in column_order
      sheet1.row(rownum).push column
    end
    for row in result
      rownum += 1
      for column in column_order
        sheet1.row(rownum).push row[column].nil? ? 'N/A' : row[column]
      end
    end
    book.write "#{excel_filename}.xls"
 
end

Here’s what the code would like in your rake task

column_order = ["Name", "DOB", "Rank","Hire Date", 
                "Height", "Weight" ]
 
sql =<<-END
  SELECT name AS Name,
   date_of_birth AS DOB, 
   rank AS Rank,
   hire_date Hire Date,
   height AS Height,
   weight AS  Weight
  FROM fire_fighters
  ORDER BY name
END
 
conn  = ActiveRecord::Base.connection
result    = conn.select_all(sql)
 
excel_filename = "FireFighterReport#{Time.year}" 
worksheet_name = "FireFighter Report #{Time.year}"
spreadsheet_report(excel_filename, worksheet_name, 
                   column_order, result)

Now, that’s easy!

Ruby Spreadsheet Gem Documentation

categoriaMysql, Programming commento1 Comment dataJune 17th, 2009
Read All

JavaScript InfoVis Toolkit: THE JIT

By kenglish

Saw a cool post on Ajaxian about a Javascript Toolkit for Data Visualization called JavaScript InfoVis Toolkit . Looks pretty cool. Checkout the demos, I especially dig the pie charts.

categoriaUncategorized commentoNo Comments dataJune 15th, 2009
Read All

JsLint to the rescue

By kenglish

This morning my JavaScript was causing an error in IE 6. The error was : “ERROR: ‘isFormField’ is null or not an object” which makes sense only to one guy at Microsoft who also happens to have collection Sub-Saharan lizards.

I got a hint that it might be a trailing comma somewhere in my JavaScript I stated pasting my code into jslint.com and was surprised at what a useful tool this is. Not only did it help me find my trailing comma, it showed me some other cool fixes I could do to my code.

categoriaUncategorized commentoNo Comments dataJune 8th, 2009
Read All

svn2git for real men

By kenglish

On the server, set up the remote repositories:

1
2
3
mkdir project1.git
cd project1.git
git --bare init

Here’s a script to do them all in one shot, just modifiy the REPOS variable:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
 
REPOS="project1 project2 project3 project4"
 
for repo in $REPOS
do
    repo_dir="$repo.git"
    mkdir -p $repo_dir
    echo "Creating git directory  $repo_dir"
    cd $repo_dir
    git --bare init
    cd ..
done
exit

Now, on the workstation:

1
2
sudo apt-get install git-core git-svn
sudo gem install nirvdrum-svn2git --source http://gems.github.com

Create the authors.txt in the following format:

1
2
dburger = David Burger <email@email.com>
jdoe = John Doe <jdoe@doe.com>

For one project, do the following:

1
2
3
4
5
mkdir project1
cd project1
svn2git  https://svn.myserver.org/repos/ses --authors ../authors.txt
git remote add origin hailstorm.myserver.org:/home/kenglish/repotest/ses.git
git push --all

The script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
 
REPOS="project1 project2 project3 project4"
 
for repo in $REPOS
do
    mkdir $repo
    cd $repo
 
    cmd="svn2git https://svn.myserver.org/repos/$repo --authors ../authors.txt"
    echo $cmd
    `$cmd`
    cmd="git remote add origin hailstorm.myserver.org:/home/kenglish/repotest/$repo.git"
    echo $cmd
    `$cmd`
    cmd="git push --all"
    echo $cmd
    `$cmd`
    cd ..
    echo "DONE EXPORTING $repo" 
done
exit

Don’t diss the shell script, I leave in the echoes in case i need to test stuff out…

Note: Another option for the authors file is place it in your home directory .svn2git/authors (e.g. /home/kenglish/.svn2git/authors). Svn2git will automatically detect it and use it.
Any questions? Comments?

categoriaMysql, Programming, Tech commento2 Comments dataMay 21st, 2009
Read All

VI key bindings for NetBeans

By kenglish

I’ve moved to NetBeans. Sorry RubyMine but now that I know that Netbeans has a vi plugin, I’m hooked

categoriaUncategorized commento1 Comment dataApril 29th, 2009
Read All