About ruby on rails, hackintosh, iphone3g and etc.

Saturday, March 7, 2009

Attachment_fu Installation

Installing Attachment_fu plugin steps as follows:

1. Install Freeimage plugin for image processing:

sudo port selfupdate

sudo port install freeimage (link)

MacPorts installation notes can be obtained from here.


2. Install ImageScience

sudo gem install -y image_science


3. Install Attachment_fu


script/plugin install http://svn.techno-weenie.net/projects/plugins/attachment_fu/

Wednesday, March 4, 2009

Mongrel_rails

To use mongrel_rails in production, you need to create a service to run in your Windows Server.

Navigate to the directory where rails app are located.

Replace (service name) including bracket with your service name .
Here is the command:

Install service:
mongrel_rails service::install -N (service name) -e (environment. e.g. production) -p (port to be used)

Remove the service:
mongrel_rails service::remove -N (service name)

That's all. Then you can configure lightttpd to point to the mongrel web app.

To start the service from command line:
net start (service name)

Saturday, February 28, 2009

Uninstall SleepWatcher

To unistall SleepWatcher (an useful tool for sleep/wake in OSX)

uninstalling sleepwatcher:

go to terminal
sudo rm /usr/local/sbin/sleepwatcher
sudo rm /usr/local/share/man/man8/sleepwatcher.8
sudo rm /etc/rc.sleep
sudo rm /etc/rc.wakeup

go to finder delete: /Library/StartupItems/SleepWatcher

need your passwd

Thursday, February 26, 2009

SQL SUM() in Rails

In Rails, Active Record support many types of calculations. It saves us from executing SELECT SUM(x) using the query. Everything can be shorten down one line of code.

Example:
To find sum of all items in a location:

Item.sum('location_id', :conditions =>['location_id = ?', location.id])

Similar to avg and others. See ActiveRecord API for more info.

Hackintosh X61 updated to 10.5.6

Finally managed to find some time and courage to update the Thinkpad X61 to 10.5.6.


Everything is ok now after initial problem with keyboard and pointing stick. I used the steps below:

1. Download PC-EFI ver 9.0. Install it. Link.
2. Download DDT-Path tool and run it. Link.


3. Notebook User: Get the PS/2 fix reader. Download from here. Also, you have to get ready usb keyboard and mouse as PS/2 mouse and keyboard may not functional after the 10.5.6 update.
3. Reboot your computer to make sure everything is fine.
4. Download OSX 10.5.6 update from Apple. If update from 10.5.5 (you can use the delta update), the rest use the combo update.

5. If you encounter error like system freeze during installation, restart your computer. Remove any external monitor connected (if you are using notebook). Reapply the 10.5.6 update. Reboot again.

6. If you encounter problem like sleep image has garbaged. You can disable deep sleep and remove earlier image at this path:

Disable Safe Sleep first:

To disable safe sleep, run the two following commands in Terminal:
$ sudo pmset -a hibernatemode 0 $ sudo nvram "use-nvramrc?"=false

Fire up Terminal. Run this

cd /var/vm

There is a file name called sleepimage. Delete this file by:

sudo rm sleepimage.

7. That's all. You can run Software Update to update the rest of security patches, Safari updates or iWork 08 patches and etc which requires 10.5.6.


Sunday, February 22, 2009

Install github on Mac OSX

Github is very useful for Ruby on Rails programmers. A lot of plugins and sample codes available. To use git in Mac OSX, you will need to install github by the following link:


Download the installer for OS X. That's all.

Open Flash Chart

OpenFlashChart is an excellent flash based charting tool. It has been ported to Ruby. A very useful tutorial by pullmonkey.com http://pullmonkey.com/2008/7/25/using-a-database-to-populate-an-open-flash-chart-graph.

To install the plugin:

script/plugin install git://github.com/pullmonkey/open_flash_chart.git

Then, copy swfobject.js from the plugin's assets/ directory. 

That's all. For coding steps, please refer to the link above.

"Code below extracted from pullmonkey.com"

open_flash_chart_object()

Usage:

This method returns only the graph html:
@graph = open_flash_chart_object(....)

Arguments

  • width (required)
  • height (required)
  • url (required)
  • use_swfobject (optional and defaults to true)
  • base (optional and defaults to "/")
  • swf_file_name (optional and defaults to "open-flash-chart.swf")