Quick tip, especially if you use GitHub with Gravatar so a little profile picture will show up on GitHub you likely need to set your Author and Email for Git. So instead of falling back to your system username and machine name for an email address (at least on the Mac), and your account's long name for author name, Git will use the correct information and your gravatar will show up in GitHub (minimally just match your email with your Gravatar account).

Run the following commands:

git config --global user.name 'Your Name'
git config --global user.email ben@domain.com

This will add entries to your ~/.gitconfig file under the [User] section.

Thats it. See me on GitHub here: http://github.com/unilogic

Thanks Tim for the correct way of doing this.
Resource: http://cheat.errtheblog.com/s/git

To expand on my last post about fixing the home and end keys in Terminal here is how to fix the Page Up and Page Down keys.

Follow the directions in my last post, but instead of choosing the end or home keys select the page up and page down keys.

Set action to send string to shell and in the text box copy and paste: \033[6~ for page down, and \033[5~ for page up in the text box under the action pull-down.

If you can't copy and paste, the key sequence goes as the following: ESC [ 6 ~ and ESC [ 5 ~ respectively. Those two key sequences should expand to the above text.

By default in Terminal.app the home and end scroll the the top of the screen and the end of the screen buffer respectively. To make Terminal act like a normal console (in other words the home key moves the cursor to the beginning of the line, and the end key moved the cursor to the end of the line, etc) do the following:

  • Open Terminal
  • Open Terminal's preferences
  • Goto the Settings Tab
Read the rest of this entry

Introduction

I have been using NetBeans 6.1 IDE for some time forcing myself to use JRuby because of the issues that NetBeans has with Ruby. I must say my experience thus far has been superior to any NetBeans release to date. That being said I am planning on using this post to list potential to make the core NetBeans 6.X/7.X the best release for Ruby on Rails developers.

Enhancement Requests

I want to preface this section of the post with the fact that I feel NetBeans is a wonderful IDE and has many features that many Java developers benefit from. That being said this is by no means discrediting any of the wonderful advancements they have brought to the Rails IDE arena.

Permissions

Using NetBeans 6.1 without JRuby is just a hassle. The implementation either needs to be dropped or made more seamless.

Gem Management

There needs to be a better quicker way to manage gems. Currently it is a long painful process which is different from what Rails developers are used to. I am a die-hard Mac OS X Rails developer and I am used to opening up the terminal and managing my gems there. I thing the best solution for this is to have a jruby/gem console that opens the terminal with the correct PATH specified and all the gem management can be done right there.

Rake Tasks

Rails developers prefer using their keyboards with shortcuts. We are used to quick editors that have great keyboard support. The editor that comes to mind is TextMate. That being said I feel there must be a better way to run rake tasks and other commands that are run frequently through the command line.

Source Code Management

GIT is the new hotness in the rails world and there needs to be solid support for git in NetBeans. There is not much of a message here except for that git support is a must.

Capistrano Integration

This would make NetBeans a HUGE success. Integration with Capistrano for developers to deploy their application. There could be some sort of collaboration on deployment where you can test each app that is marked for deployment on a local glassfish server and then one of the choices get deployed out to production.

Conclusion

Any of the above enhancement requests are welcome to collaboration and improvement via commands or email. I look forward to your comments.

Introduction

Git has become quite the popular version control system in the rails community. That being said I am announcing that I will stop using ports for my tutorials and install everything from source. There are advantages and disadvantages to this and the main reason is that I am sick of waiting for ports that are outdated.

Requirements

This install is quite easy. All the dependencies required ship with Mac OS X Leopard. That being said lets get started. For this to install successfully you must have the following installed on your computer:

  • Apple Developer Tools

Installation

Download the latest package from Git At the time of writing this tutorial the current version is Git 1.5.5.

Below are the directions to completely install the Git version control system.


cd /usr/local/src
curl -O http://kernel.org/pub/software/scm/git/git-1.5.5.tar.bz2
tar -xjf git-1.5.5.tar.bz2
cd git-1.5.5
./configure --prefix=/usr/local
make
sudo make install

Ruby Performance Revisited

February 20th, 2008

For this post I used a code snippet I found from a fellow programmer, Antonio Cangiano, that ran the tests again myself because I couldnt believe my eyes of the benchmarks run by that user.

Fibonacci Language Shootout:

Languages

  • Ruby 1.8.6
  • Ruby 1.9.0 (Development Release)
  • Python 2.5.1
  • Perl 5.8.8
  • Java 1.5.0
  • C++

Below are the languages and the times that each took to run the code. The code for each languages is below near the end of the post.

Ruby 1.8.6


real    0m44.965s

Python 2.5.1


real    0m28.283s

Ruby 1.9.0


real    0m11.352s

C++


real    0m0.765s

Java


real 0m0.638s

Perl


real 0m70.383s

I will be comparing this performance of Ruby and Python to a program written in C. Below is the code used in these examples. Feel free to comment. I am running further tests using statistical analysis to make the output exhibit less of a standard deviation.

Python


def fib(n):
   if n == 0 or n == 1:
      return n
   else:
      return fib(n-1) + fib(n-2)

for i in range(36):
    fib(i)

Ruby

1
2
3
4
5
6
7
8
9
10
11
12

def fib(n)
  if n == 0 || n == 1
    n
  else
    fib(n-1) + fib(n-2)
  end
end

36.times do |i|
  fib(i)
end

Below is the source code for the fib sequence written in C++. Paul Solt recommended that the tests be performed without and writing to STDOUT due to the variability and slow down caused by writing to STDOUT. Since this was done for the C++ code it was done for the rest of the examples above. For the record there was no increase in speed when the output was removed.

C++


#include 
#include 

int fib( int n ) { 
    if( n== 0 || n == 1 ) { 
        return n; 
    } else {
        return fib( n -1) + fib( n-2); 
    }
}

int main() { 
    for( int i = 0; i < 36; i++ ) {
        fib(i);
    }
    return 0; 
}

Java


public class fibtest {
    public static void main(String[] args) { 
        for(int i=0; i<36; i++) {
            fib(i);     
        }
    }
    public static int fib(int n) {
        if( n == 0 || n == 1 )
            return n; 
        } else {
            return fib(n-1) + fib(n-2);
        }
    }
}

Perl


sub fib { return $[0] if $[0] == 0 || $_[0] == 1; fib($[0]-1) + fib($[0]-2); }

for($i=0;$i<36;$i++) { fib($i); }

I would like to extend my thanks to the developers that submitted, or contributed to this post in anyway.

Ruby & Python Code

Paul Solt - C Developer

Java & Perl Code - Jason Koppe

Introduction

I have a reason to believe that Ruby is broken yet again on Leopard. That being said there are a few options ruby developers have to fix said issue.

I encourage reader comments on this issue...

irb

require 'rubygems'

=> false

As you can see rubygems fails to load.

Read the rest of this entry

The best and fastest solution to have a solid terminal emulation product that is free on Mac OS X Leopard is to just use minicom.

sudo port install minicom

sudo minicom -s

Configure minicom to your liking. If you need to find you device to configure minicom with just run

ls /dev | grep tty.*

tty.usbserial

Add /dev/tty.usbserial to the modem line in the configuration. Save the config as default and select exit

Just another reason to never use crappy drivers, TextMate throws and error when run from the command line after Logitech Control Center 2.4 is installed. Remove the drive via the "LCC Uninstaller" and reboot. After that everything will be hunky dory again.

Note: There are three other good alternatives to that mouse driver including SteerMouse, USBOverdrive, and ControllerMate.

Introduction

In the past it has been somewhat interesting to install rmagick and imagemagick on leopard. This is because of the tiff port in MacPorts failing to compile. I prefer MacPorts for jobs like this because if there are any security vulnerabilities in ImageMagick I would easily be able to update it and any of its dependencies with MacPorts and it would not be as easy when compiling from source. That being said lets move on.

Requirements

Read the rest of this entry

In the name of performance Apple has in Tiger and Leopard decided that cacheing DNS lookups locally was a good idea. Normally it is, but when you are debugging DNS problems or changing DNS records it can be quite a pain if you forget about it. Well as long as you remember, its simple enough to clear the cache:

Tiger
lookupd -flushcache

Leopard
dscacheutil -flushcache

Source: http://www.opendns.com/support/article/209

Introduction

The purpose of this post is to quickly and efficiently update you Ruby on Rails stack on Mac OS X Leopard.

Requirements

Caution: Before this procedure is start you must have a cursory knowledge of using the Terminal in Mac OS X.

  • Fully Patched Install of Mac OS X Leopard
  • Apple Developer Tools

Procedure

  1. Open Terminal

  2. Run the following

    sudo gem update --system

  3. Run the following command to update all your installed gems to the latest version

    sudo gem update

  4. That is it!

Note: All the previously installed gems will stay installed as a backup but ruby will use the latest gems that are installed on the system.

Wireshark on Mac OS X Leopard

December 3rd, 2007

Today I will be posting on a complete setup of wireshark for leopard. We will be using the MacPorts package manager in order to stay at the latest version with ease. There are a couple other versions available but I have found this one to be the best solution available.

Note: Mac OS X Leopard has moved to the Xorg codebase so there are a couple tricks and tradeoffs that exist when running X11 applications.

Run the following command to have a fully working wireshark setup.

sudo port install wireshark +x11

There is another variant which is +quartz but currently the versions of cairo and gtk2 working with the quartz libraries are very experimental and do not work well as of yet.

UPDATE: It appears with the current version 2.0 of XQuartz that is shipped with Leopard is a bit broken and Wireshark will crash quite quickly after you start to capture. See bug 1953. The solution to this is to update XQuartz to 2.1.0.1 or greater. To do this download http://xquartz.macosforge.org/downloads/X11-2.1.3.pkg and install it. This will update the shipped version.
Note: You need to have X11 already installed from the Apple Leopard DVD for this update to install.
Note: This is not an official Apple update for X11. We're not really sure, when an official update comes out, how well it will install.

Introduction

The main purpose of this howto is to offer instructions on how to setup a development stack for Mac OS X Leopard. There will be no beefy server backend so the web hosting portion of this tutorial will stop at mongrel. I will be using the built in rails stack and just updating the necessary packages. Now lets get this solid foundation patched and development ready. Enjoy.

Environment

Leopard ships with Ruby 1.8.6 patchlevel 36 with extra goodies that got merged in. The reason why Ruby was not the latest which is available today for download from Ruby-Lang is because it was released after the deadline. Do not fret the security vulnerabilities were patched. Since the version that ships with Leopard is "framework-ized" we will stick with that version and updating the Ruby on Rails installation around it.

Pre-Installed Gems

Below is a list of all the gems that come installed on a default Leopard install. The stack below is before anything has been done to a clean OS X install. We will use this as the base of our stack and build from here.

  • actionmailer (1.3.3)
  • actionpack (1.13.3)
  • actionwebservice (1.2.3)
  • activerecord (1.15.3)
  • activesupport (1.4.2)
  • acts_as_ferret (0.4.1)
  • capistrano (2.0.0)
  • cgimultiparteof_fix (2.2)
  • daemons (1.0.7)
  • dnssd (0.6.0)
  • fastthread (1.0)
  • fcgi (0.8.7)
  • ferret (0.11.4)
  • gem_plugin (0.2.2)
  • highline (1.2.9)
  • hpricot (0.6)
  • libxml-ruby (0.3.8.4)
  • mongrel (1.0.1)
  • needle (1.3.0)
  • net-sftp (1.1.0)
  • net-ssh (1.1.2)
  • rails (1.2.3)
  • rake (0.7.3)
  • RedCloth (3.0.4)
  • ruby-openid (1.1.4)
  • ruby-yadis (0.3.4)
  • rubynode (0.1.3)
  • sources (0.0.1)
  • sqlite3-ruby (1.2.1)
  • termios (0.9.4)

Updating Current Environment

First things first we need to update RubyGems is 0.9.5 which is fully supported by Leopard. To complete this step please run the following command in the terminal.

sudo gem update --system

Once this completes RubyGems will be fully patched and you will be ready to update the Ruby on Rails gems to their latest version.

Upgrading Installed Gems

Now that RubyGems is updated we are ready to update all the installed gems on the system.

sudo gem update

Once that has completed you will not have the latest version of stable rails as well as all the other fabulous gems that ship with Mac OS X.

Testing Your New and Updated Ruby on Rails Stack

cd ~/Sites
rails Test
cd Test
./script/server &

open http://localhost:3000

Adding Support For PostgreSQL Databases

In the next post on this topic I will be going over how to add support for PostgreSQL 8.2.5 as well as compiling PostgreSQL with DTrace support under Mac OS X.

Stay Tuned...

If you have ever had an issue with System Preference Icons disappearing or changing to some odd looking icon then run the following command to reset you caches for the preference pane and it will rebuild the icons.

rm ~/Library/Caches/com.apple.preferencepanes.*