Installing do_postgres on MacPorts
Ensure that pg_config is in your $PATH.
[block:important]This expects you are using PostgreSQL 8.2. Alter the directories as required.[/block]
To test if pg_config is included, execute which pg_config [image16x16:terminal]:
Expected Result:
[block:terminal]/opt/local/lib/postgresql82/bin/pg_config[/block]
Including pg_config into your $PATH
If you don't get anything, then it isn't in your path. Append the following to your ~/.profile file:
[block:terminal]export PATH=$PATH:/opt/local/lib/postgresql82/bin[/block]
Now it will be included in all new terminal sessions.
Installing do_postgres
Now feel free to install the do_postgres gem.
[block:terminal]sudo gem install do_postgres -- \
--with-pgsql-include-dir=/opt/local/include/postgresql82/ \
--with-pgsql-lib-dir=/opt/local/lib/postgresql82/[/block]
Automatically Restart script/server For Easier Plugin Development with FSEvents
When developing a Rails plugin, you are required to restart the server so that your plugin will be reloaded. You'll notice that after a while this becomes a rather tedious process, especially if you are working on a hot-off-the-press new plugin.
Following suit on my autotest with FSEvents, I opted to listen for any changes to the vendor/plugins and lib directories to restart the server as required. Thus freeing me of the horrible grunt work of restarting the server.
Note: This is Mac OS X 10.5 Leopard specific.
The Incantation
Create the required file script/autorestart_server, and put this beauty in it.
For an easy to copy dump, click "view plain".
Note: Don't forget to make it executable! chmod u+x script/autorestart_server
#!/usr/bin/env ruby
PATHS_TO_OBSERVE = /^(lib|vendor\/plugins)/
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
include OSX
def start_server
IO.popen("script/server #{ARGV.join(' ')}")
end
def stop_server(io)
return if io.nil?
Process.kill("INT", io.pid)
end
io = start_server
callback = proc do |stream, ctx, numEvents, paths, marks, eventIDs|
paths.regard_as('*')
rpaths = []
length = Dir.pwd.length + 1
numEvents.times { |i| rpaths << paths[i][length..-1] }
next if rpaths.select { |path| path =~ PATHS_TO_OBSERVE }.empty?
stop_server(io)
puts "Restarting server"
io = start_server
end
stream = FSEventStreamCreate(KCFAllocatorDefault, callback, nil, [Dir.pwd], KFSEventStreamEventIdSinceNow, 1.0, 0)
unless stream
puts "Failed to create stream"
exit
end
FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), KCFRunLoopDefaultMode)
unless FSEventStreamStart(stream)
puts "Failed to start stream"
exit
end
begin
CFRunLoopRun()
rescue Interrupt
stop_server(io)
FSEventStreamStop(stream)
FSEventStreamInvalidate(stream)
FSEventStreamRelease(stream)
end
Automatically Restarting script/server
Now feel free to execute script/autorestart_server
Wondering where else I can inject FSEvents into, its quite a handy little tool...
Leopard vs Gutsy Gibbon
So with my laptop in the state of no return, I have been pondering what my next machine will be. Of course a machine would be empty without its operating system!
Repairs alone would cost more than 1700 MYR, so rather than dumping that money on an old machine, I thought I'd invest in a new one. I've been looking around the market, but my eyes have been fixated on the low end Macbook. I don't really need Apple hardware, but after comparing it with the IBM/Lenovo ThinkPads, that are currently available, the Macbook provides a better bang for the buck!
What are the extra benefits of getting a Macbook? Leopard! (well soonish, its only Tiger for now)
Rumors have it that Apple is just about to release (somewhere around October 26) their update to their operating system, dubbed Mac OSX 10.5 Leopard, featuring more bling. Meanwhile the Ubuntu community have also been hard at work on their next version 7.10 Gutsy Gibbon, to be released on October 18th!
Sure I could just buy the Apple hardware and dump Ubuntu on it, but Mac OSX is oh so blingy, though Ubuntu is also very blingy with Compiz!
So my options?
- Wait till the end of October, or beginning of November to get Leopard preloaded on a Macbook
- Get the Macbook now and load Leopard (or whatever comes next) later
- Purchase a non Apple laptop, and use Ubuntu
Perhaps someone would like to donate me a laptop? It will most definitely make me decide on my next operating system. Please.
Or perhaps I should just consider another brand...Dell, HP? Any recommendations? Definitely not Acer though.
