Installing Oniguruma on Mac OS X Leopard
December 23rd, 2008
Introduction
So many of you may be trying to get oniguruma installed on Mac OS X Leopard + MacPorts. You may not know that the gem does not allow for a custom directory for the oniguruma package. This poses to be an issue if installed via MacPorts.
That being said I have research the solution to this annoying problem.
Setup
- sudo port install oniguruma5
- sudo gem install oniguruma
Note: This will fail
- cd /Library/Ruby/Gems/1.8/gems/oniguruma-1.1.0/ext
- vim extconf.rb
Make your extconf.rb file look like this
require 'mkmf'
dir_config("onig")
if have_library("onig")
$CFLAGS='-Wall'
create_makefile( "oregexp" )
else
puts "Cannot find lib-oniguruma. Set location with e.g. --with-onig-dir=/opt/local"
exit 1
end
Save and Quit Vim
- rake gem
-
sudo gem install --local pkg/oniguruma-1.1.0 -- --with-onig-dir=/opt/local
Now you are all set!
— Ron Valente
Setting you HostName in Mac OS X
December 14th, 2008
Tip of the Day – Setting Hostname on Mac OS X 10.5
So if you are a road warrior and travel around a lot. You may be annoyed by your terminal displaying your DHCP hostname rather than the real hostname of your machine. That being said here is a simple way to permanently fix your problem.
sudo scutil --set HostName
Enjoy!
Solaris 10 Time Machine Server with ZFS Backend
November 16th, 2008
Introduction
Wow, this process is a huge pain in the ass. I have been going back and fourth between changing sources files and configure statements. I will be documenting this whole process here to save everyone else the trouble. If you want to setup a TimeMachine server with a ZFS back end you will need this guide more than anything else. I will be using a Solaris 10u6 installation booting from ZFS as well.
More information as well as source patch files will come soon!
Overview
Considering this was not an easy process I will be trying to explain everything as well as possible. Basically the netatalk package supports Solaris 9 just fine, Solaris 10 changes the way it plays the game. With all the improvements there also came some compromises.
Read the rest of this entryTip of the Day: Set Git Author and Email [Updated]
May 13th, 2008
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
Programming Rails Applications on NetBeans 6.1
April 14th, 2008
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.
TOTD: Installing Git on Mac OS X
April 14th, 2008
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.
Java & Perl Code - Jason Koppe
Ruby Broken on Leopard [Not Really]
February 19th, 2008
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 entryTerminal Emulation on Mac OS X Leopard
February 18th, 2008
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
TextMate & Logitech Control Center
January 29th, 2008
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.
Ruby on Rails with ImageMagick and rmagick on Leopard
January 27th, 2008
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
- Fully Patch Mac OS X Leopard 10.5.1
- Apple Developer Tools
- Updated Ruby on Rails
- MacPorts
Tip of the Day - Clearing Local Resolver Cache
January 20th, 2008
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
Updating Ruby on Rails on Mac OS X Leopard
January 7th, 2008
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
Open Terminal
Run the following
sudo gem update --system
Run the following command to update all your installed gems to the latest version
sudo gem update
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.