X-Chat Aqua continuing development

X-Chat Aqua
My all-time favourite OSX IRC client, X-Chat Aqua haven’t seen updates in quite some time, leaving happy users in the dust; it was working but also was showing some aging.

Recently this project took a good step, thanks to Steven Noonan we can enjoy this client again, since he overtook the development.

Please visit his page to know more and download latest stable.

$1.99 domains with SSL purchase!

TextMate and Snow Leopard compatibility

Snow Leopard TextMate compatibility bundle

Update: Allan released a new Snow Leopard compatible build which does contains those workaround, therefore this bundle should not be necessary anymore, just update your TextMate copy.

There seems to be some problems with TextMate in Snow Leopard; for instance cmd+arrows doesn’t work by default.

Meantime Pat get his stuff sorted out you can download a TextMate bundle that tries to fix the problem.

Grab it here.

Remove every file that a .pkg provides on OS X

pkg_iconSometimes we have to install new software that comes only into a form of .pkg .

Sadly when we are done with it and decide to uninstall, developers didn’t took this into account, leaving all kind of files in our system.

This line of code tries to take care of those files.

lsbom  -f -l -s /Library/Receipts/package_here.pkg/Contents/Archive.bom  | (cd /; sudo xargs rm)

Disable Safari Web Previews

Safari is a great browser, however the 4th version added a “feature”: it takes png screenshots of every web page you visit.

This have two issues, at least for me: privacy and disk space.

To disable this feature open a terminal and write:

defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

Close and restart Safari. Click on Safari menu at the top and select Reset, be sure to check ‘Remove all webpage preview images’, execute.

topsites

To restore the default settings quit Safari and write in terminal:

defaults delete com.apple.Safari DebugSnapshotsUpdatePolicy

Send SMS with Ruby on Rails

SMSOnce upon a time embedding the chance to send SMS withing an app was daunting, no more.

We are going to use Ruby on Rails Edge (git version, but should work on stable too) and the excellent SmsOnRails plugin, along with Clickatell SMS provider.

Open your project with your favourite text editor and edit config/environment.rb by adding gem requirement:

1
2
config.gem 'blythedunham-sms_on_rails', :lib => 'sms_on_rails', :source  => 'http://gems.github.com'
config.gem 'clickatell' # if using Clickatell

Install the gems:

sudo rake gems:install

Or if you’re not going to use gems, install as plugin:

script/plugin install git://github.com/blythedunham/smsonrails.git

The plugin itself is complete with generators, for both models and migrations, I will not show them here (even because rails edge still cannot handle gem generators as of this writing), instead I will show you how to send sms quickly and easily.

We are going to use one specific provider for sending our sms, it’s Clickatell.
Therefore go to their website and open an account to use Clickatell Central API.
Account starts with a balance of 10 SMS, on which you cannot add custom text, but once you buy a proper package those limitations wears off (of course).

After you open up your account, proceed in buying sms at your liking, after that click on My Connections.

From here you can add a new HTTP connection by clicking Add Connection select box – HTTP.
You can leave the fields blank in the form that will appear on page reload, but for extra security you better edit them soonish.

When you add a new connection, it will get assigned a API ID, most likely it’s numeric.

Back to our plugin configuration, keep in mind that SmsOnRails also inherits settings from ActionMailer, so it can send also emails instead of SMS.

Create a new file called sms.rb in config/initializers directory and write this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SmsOnRails::ServiceProviders::Clickatell.config =
{
   :api_id => 'numeric_api_id',
   :user_name => 'your_username',
   :password => 'your_password'
}
 
 
SmsOnRails::ServiceProviders::EmailGateway.config =
{
   :sender => 'no-reply@domain.com',
   :subject => 'Default Subject Text'
   #:bcc => nil,
   #:mailer_klass => nil
}
 
 
SmsOnRails::ServiceProviders::Base.set_default_service_provider :clickatell

Replace api_id, user_name and password with your data.
As you can see we set our provider as Clickatell.

There are different methods for sending a SMS, and service providers are singletons and can be accessed by their instance.

Therefore:

1
2
3
phone_number = '392848676093485693' # not a real number
message_text = 'hi'
SmsOnRails::ServiceProviders::Clickatell.instance.send_message(phone_number, message_text)

That’s it. Easy as pie.
SmsOnRails is a robust plugin, pings the clickatell service to keep the connection alive.
I have yet to find out a way to show a custom sender ID, but for now, it’s fine and works well.

Advanced configurations can be seen at the github project page.

Install MySQL and MySQL Ruby gem on Snow Leopard, 64 bit

Warning: I consider this tutorial outdated. Please switch to a better system like brew, rvm and the mysql2 gem.

This is the source approach to get MySQL and MySQL Ruby gem working on Snow Leopard.

I assume you don’t have any previous MySQL installations lying around, this guide covers the installation from scratch.

If you want to install your ruby gems in your self-contained home directory without using sudo, check the end of the article.

Install required software

Let’s start by getting into a directory, I’ll use ~/src.
By convention you may want to use /SourceCache aswell.

Download the latest MySQL source distribution and install Xcode from Snow Leopard DVD.

While you’re downloading MySQL and installing Xcode you need to set your PATH environment variable correctly.

PATH Setup

Open a Terminal and verify what’s your current PATH by doing this:

echo $PATH

This will return a string containing the current search paths, you have to make sure that’s containing /usr/local/bin, /usr/local/sbin and /usr/local/mysql/bin.

Don’t rely on your terminal application to set those paths; instead go ahead and edit/create the file .bash_profile (file that starts with a dot are hidden) in your home folder (~).

As a Textmate user I’ll use the mate command to fire up my editor.

mate ~/.bash_profile

Inside this file, write:

PATH="/usr/local/bin:/usr/local/sbin:$PATH" # if not already present
PATH="$PATH:/usr/local/mysql/bin"
export PATH=$PATH

With this in place we are sure that we will find MySQL required files later.

If you don’t want to reopen the terminal or switch to another tab, just execute:

source ~/.bash_profile

This will pickup changes to $PATH.

MySQL installation

Decompress the MySQL source:

tar xzvf mysql-5.1.40.tar.gz && cd mysql-5.1.40

Of course match the version number you downloaded, the latest as of this writing is 5.1.40.

Configure MySQL this way (one line):

CC=gcc CFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared --with-plugins=innobase

Compile MySQL and install:

make && sudo make install

We are not done with MySQL yet, we need to install default tables and set up permissions:

cd /usr/local/mysql
sudo ./bin/mysql_install_db --user=mysql
sudo chown -R mysql ./var

We now have to auto start MySQL upon booting.
Create a file named

com.mysql.mysqld.plist

and add the following code in it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <true />
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/usr/local/mysql/bin/mysqld_safe</string>
    <key>RunAtLoad</key>
    <true />
    <key>UserName</key>
    <string>mysql</string>
    <key>WorkingDirectory</key>
    <string>/usr/local/mysql</string>
</dict>
</plist>

or see the script on github (raw).

Next move this file in the proper place with sudo and assign correct permissions:

sudo mv ~/src/com.mysql.mysqld.plist /Library/LaunchDaemons
sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist

Start up MySQL now with:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

To stop MySQL manually do:

sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

MySQL should be running (unless you stopped it, eh), it’s time to change our MySQL root’s password:

mysqladmin -u root password "mypassword"

Replace mypassword with your password.

Test MySQL:

mysqladmin -u root -p version

Write your password when asked and you should see some useful data.

Time to install the ruby mysql bindings gem.

MySQL Ruby gem setup

Please see the section below for a note about sudo.

First, update rubygems.

sudo gem update --system

If this doesn’t work for some reason or you get “Nothing to update” try this instead:

sudo gem install rubygems-update
sudo update_rubygems

Time to build our gem, write:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

And we are done, thanks for reading.

Extras

Not always is desiderable to install gems system-wide, so add this to your .bash_profile

export GEM_PATH="$HOME/.gem/ruby/1.8"
export GEM_HOME="$HOME/.gem/ruby/1.8"
PATH="$HOME/.gem/ruby/1.8/bin:$PATH"
export PATH=$PATH

This will self-contain gem files and binaries in your home directory and you can install gems without using sudo.

Bonus
My entire .bash_profile:

export GIT_EDITOR="/usr/bin/mate -w"
export EDITOR="/usr/bin/mate -w"
export RAILS="$HOME/src/rails"
export GEM_PATH="$HOME/.gem/ruby/1.8"
export GEM_HOME="$HOME/.gem/ruby/1.8"
 
# CAPP_BUILD, directory for built Cappuccino framework.
export CAPP_BUILD="$HOME/src/cappuccino_framework"
 
# Cappuccino jake branch.
PATH="$CAPP_BUILD/Release/CommonJS/objective-j/bin:$PATH"
PATH="$HOME/src/narwhal/bin:$PATH"
 
# Normal stuff.
PATH="$PATH:/opt/local/sbin"
PATH="$PATH:/opt/local/bin"
PATH="$PATH:/usr/local/mysql/bin"
PATH="$HOME/.gem/ruby/1.8/bin:$PATH"
 
# Finalize PATH
export PATH=$PATH
 
function parse_git_branch {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo "("${ref#refs/heads/}")"
}
 
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
 
PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ "

Install ImageMagick in Leopard / Snow Leopard

ImageMagick

This is a bash script that attempts to download, extract and compile what’s required in order to successfully install ImageMagick on Snow Leopard.

Update: I moved the script on github.

Update 2: there are now much better systems to install utilities like this. Check out Homebrew for example.

Boot Snow Leopard in 64 bit kernel mode

64bitSeems like Snow Leopard doesn’t boot automatically in 64 bit mode on certain machines, it does however on servers.

To try out the 64 bit kernel edit this file:

/Library/Preferences/SystemConfiguration/com.apple.Boot.plist

and add the architecture like this:

< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Kernel</key>
	<string>mach_kernel</string>
	<key>Kernel Flags</key>
	<string>arch=x86_64</string>
</dict>
</plist>

Pay special attention to the spaces between the first two tags and remove them, this is caused by WordPress bad formatting and are unintentional.

Reboot.

There are other two ways, by pressing ’6′ and ’4′ keys when booting up (or ’3′ and ’2′ to boot in 32 bit) or writing in terminal:

nvram boot-args="arch=x86_64"

and reboot.

CentOS “gem install mysql” problems, solution

checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Be sure to have mysql and mysql-devel packages, and install the gem with

gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql

Passenger (mod_rails) $PATH on Leopard / Snow Leopard

Passenger uses a little subset of your PATH.

So if you have installed ruby, gem and misc binaries in other paths you cannot access them via your passenger rails application.

Create an executable script ruby_with_env, I wrote it in my /usr/local/bin:

1
2
3
4
#!/bin/bash
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/graphviz/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/local/git/bin/
:$PATH"
/usr/local/bin/ruby $*

Now point the file to your PassengerRuby directive in your apache configuration file and restart.