<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: osx code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 12 May 2008 07:28:47 GMT</pubDate>
    <description>DZone Snippets: osx code</description>
    <item>
      <title>OS X version detection in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5454</link>
      <description>// detects OS X version&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt; `osascript -e 'tell application "Finder"\nreturn version\nend tell'`.chop!&lt;br /&gt;=&gt; "10.5.3"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 02 May 2008 19:01:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5454</guid>
      <author>tom.morris (Tom Morris)</author>
    </item>
    <item>
      <title>Recursively Remove .DS_Store files in OS X (More optimized)</title>
      <link>http://snippets.dzone.com/posts/show/4985</link>
      <description>Recently, I saw a this snippet :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;alias rmdsstores='find ./ -type f | grep .DS_Store | xargs rm'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;But this one is not very optimized, because you have two pipes with command call.&lt;br /&gt;&lt;br /&gt;You can do exactly the same, with only the 'find' command, here the code :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;alias rmdsstores='find . -name *.DS_Store -type f -exec rm {} \;'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 15 Jan 2008 16:07:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4985</guid>
      <author>Batzooh (Batzooh)</author>
    </item>
    <item>
      <title>Recursively Remove .DS_Store files in OS X</title>
      <link>http://snippets.dzone.com/posts/show/4982</link>
      <description>This shell alias will recursively remove all .DS_Store files from the current directory up.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;alias rmdsstores='find ./ -type f | grep .DS_Store | xargs rm'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 14 Jan 2008 03:07:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4982</guid>
      <author>justinwr (Justin R)</author>
    </item>
    <item>
      <title>install rmagick on leopard</title>
      <link>http://snippets.dzone.com/posts/show/4798</link>
      <description>&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz&lt;br /&gt;tar xzvf freetype-2.3.5.tar.gz&lt;br /&gt;cd freetype-2.3.5&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.22.tar.bz2&lt;br /&gt;tar jxvf libpng-1.2.22.tar.bz2&lt;br /&gt;cd libpng-1.2.22&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz&lt;br /&gt;tar xzvf jpegsrc.v6b.tar.gz&lt;br /&gt;cd jpeg-6b&lt;br /&gt;ln -s `which glibtool` ./libtool&lt;br /&gt;export MACOSX_DEPLOYMENT_TARGET=10.5&lt;br /&gt;./configure --enable-shared --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz&lt;br /&gt;tar xzvf tiff-3.8.2.tar.gz&lt;br /&gt;cd tiff-3.8.2&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O http://jaist.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz&lt;br /&gt;tar xzvf libwmf-0.2.8.4.tar.gz&lt;br /&gt;cd libwmf-0.2.8.4&lt;br /&gt;make clean&lt;br /&gt;./configure&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O http://www.littlecms.com/lcms-1.17.tar.gz&lt;br /&gt;tar xzvf lcms-1.17.tar.gz&lt;br /&gt;cd lcms-1.17&lt;br /&gt;make clean&lt;br /&gt;./configure&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz&lt;br /&gt;tar zxvf ghostscript-8.60.tar.gz&lt;br /&gt;cd ghostscript-8.60/&lt;br /&gt;./configure  --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz&lt;br /&gt;tar zxvf ghostscript-fonts-std-8.11.tar.gz&lt;br /&gt;sudo mv fonts /usr/local/share/ghostscript&lt;br /&gt;&lt;br /&gt;curl -O http://imagemagick.site2nd.org/imagemagick/ImageMagick-6.3.5-9.tar.gz&lt;br /&gt;tar xzvf ImageMagick-6.3.5-9.tar.gz&lt;br /&gt;cd ImageMagick-6.3.5&lt;br /&gt;export CPPFLAGS=-I/usr/local/include&lt;br /&gt;export LDFLAGS=-L/usr/local/lib&lt;br /&gt;./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;sudo gem install RMagick&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 19 Nov 2007 21:59:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4798</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>gemdocs</title>
      <link>http://snippets.dzone.com/posts/show/4533</link>
      <description>Put this snippet into your ~/.bash_login (or alternatives) to browse your gem docs from the command line.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;function gemdocs() { &lt;br /&gt;&lt;br /&gt;  if [[ -n "$(whereis gem_server)" ]]; then&lt;br /&gt;     gem_server &gt;/dev/null 2&gt;&amp;1 &amp;&lt;br /&gt;     sleep 3&lt;br /&gt;     open http://127.0.0.1:8808/&lt;br /&gt;  fi&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 12 Sep 2007 16:57:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4533</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>pman  --  create, print, save, view PDF man pages</title>
      <link>http://snippets.dzone.com/posts/show/4274</link>
      <description>pman  --  create, print, save, view PDF man pages&lt;br /&gt;&lt;br /&gt;Author:  ntk&lt;br /&gt;License:    &lt;a href="http://www.opensource.org/licenses/mit-license.php"&gt;The MIT License&lt;/a&gt;, Copyright (c) 2007 ntk&lt;br /&gt;Description:    (batch) convert &lt;a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/"&gt;man pages&lt;/a&gt; into PDF documents and save them to a specified directory; (batch) print or view PDF man pages from the command line&lt;br /&gt;Platform:    Mac OS X 10.4.10; man bash&lt;br /&gt;Installation:    put pman() into ~/.bash_login (or alternatives)        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Usage:&lt;br /&gt;   &lt;br /&gt;pman ls; pman getopts                                 # convert a singel man page to a PDF file, save and open it&lt;br /&gt;pman 8 sticky                                         # same with manual section number&lt;br /&gt;pman m toe                                     &lt;br /&gt;pman -b ls 'open(2)' dd "chmod(2)" curl 'open(n)'     # batch convert man pages into PDF files&lt;br /&gt;pman -p rm srm open\(2\) 'toe(m)' 'ncurses(3)'        # print man pages using the default printer&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;pman() {&lt;br /&gt;&lt;br /&gt;section="$1"    &lt;br /&gt;manpage="$2"    &lt;br /&gt;&lt;br /&gt;mandir="/Users/Shared/manpages"    #  save the created PDF man pages to the specified directory&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# batch process man pages to PDF files with the "-b" switch and save them to $mandir&lt;br /&gt;# example: pman -b ls 'open(2)' dd 'chmod(2)' 'open(n)' 'sticky(8)'&lt;br /&gt;# cf. man -aW open for "man n open"&lt;br /&gt;&lt;br /&gt;if [[ "$1" = "-b" ]]; then         &lt;br /&gt;&lt;br /&gt;if [[ ! -d $mandir ]]; then        &lt;br /&gt;   mkdir -p $mandir&lt;br /&gt;   chmod 1777 $mandir&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;shift   # remove "-b" from "$@"&lt;br /&gt;&lt;br /&gt;for manfile in "$@"; do &lt;br /&gt;&lt;br /&gt;# example for $manfile: open(2)&lt;br /&gt;manpage="`echo $manfile | grep -Eos '^[^\(]+'`"                              # extract name of man page&lt;br /&gt;section="`echo $manfile | grep -Eos '\([^\)]+\)' | grep -Eos '[^\(\)]+'`"    # extract section of man page&lt;br /&gt;&lt;br /&gt;if [[ ! "$section" ]]; then&lt;br /&gt;   section="1"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [[ ! -f "`man ${section} -W ${manpage} 2&gt;/dev/null`" ]]; then&lt;br /&gt;#if [[ ! -f "`man -W ${section} ${manpage} 2&gt;/dev/null `" ]]; then&lt;br /&gt;   echo "No such man page: man ${section} ${manpage}"&lt;br /&gt;   continue&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;manfile="${mandir}/${manpage}(${section}).pdf"&lt;br /&gt;echo "$manfile"&lt;br /&gt;&lt;br /&gt;if [[ ! -f "$manfile" ]]; then&lt;br /&gt;   man $section -t $manpage 2&gt;/dev/null | pstopdf -i -o "$manfile" 2&gt;/dev/null&lt;br /&gt;   chmod 1755 "$manfile"&lt;br /&gt;   # hide file extension .pdf&lt;br /&gt;   if [[ -f /Developer/Tools/SetFile ]]; then /Developer/Tools/SetFile -a E "$manfile"; fi&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;return 0&lt;br /&gt;   &lt;br /&gt;fi          # END of batch processing man pages to PDF files&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# print PDF man pages using the default printer (see man lpr and man lpoptions)&lt;br /&gt;# if necessary, create the specified PDF man pages and save them to $mandir&lt;br /&gt;# example: pman -p rm srm&lt;br /&gt;&lt;br /&gt;if [[ "$1" = "-p" ]]; then         &lt;br /&gt;&lt;br /&gt;if [[ ! -d $mandir ]]; then        &lt;br /&gt;   mkdir -p $mandir&lt;br /&gt;   chmod 1777 $mandir&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;shift   # remove "-p" from "$@"&lt;br /&gt;&lt;br /&gt;for manfile in "$@"; do &lt;br /&gt;&lt;br /&gt;# example for $manfile: open(2)&lt;br /&gt;manpage="`echo $manfile | grep -Eos '^[^\(]+'`"                              # extract name of man page&lt;br /&gt;section="`echo $manfile | grep -Eos '\([^\)]+\)' | grep -Eos '[^\(\)]+'`"    # extract section of man page&lt;br /&gt;&lt;br /&gt;if [[ ! "$section" ]]; then&lt;br /&gt;   section="1"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [[ ! -f "`man ${section} -W ${manpage} 2&gt;/dev/null`" ]]; then&lt;br /&gt;   echo "No such man page: man ${section} ${manpage}"&lt;br /&gt;   continue&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;manfile="${mandir}/${manpage}(${section}).pdf"&lt;br /&gt;echo "$manfile"&lt;br /&gt;&lt;br /&gt;if [[ ! -f "$manfile" ]]; then&lt;br /&gt;   man -t $section $manpage 2&gt;/dev/null | pstopdf -i -o "$manfile" 2&gt;/dev/null&lt;br /&gt;   chmod 1755 "$manfile"&lt;br /&gt;   # hide file extension .pdf&lt;br /&gt;   if [[ -f /Developer/Tools/SetFile ]]; then /Developer/Tools/SetFile -a E "$manfile"; fi&lt;br /&gt;   lpr "$manfile"&lt;br /&gt;else&lt;br /&gt;   lpr "$manfile"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;return 0&lt;br /&gt;   &lt;br /&gt;fi          # END of printing man pages using the default printer&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# convert a single man page to a PDF file, save it to $mandir and then open it in a PDF viewer&lt;br /&gt;&lt;br /&gt;if [[ -z "$1" ]] || [[ $# -gt 2 ]]; then       # check number of arguments&lt;br /&gt;#if [[ -z "$1" || $# -gt 2 ]]; then  &lt;br /&gt;#if [ -z "$1" -o $# -gt 2 ]; then&lt;br /&gt;  echo "Wrong number of arguments!" &lt;br /&gt;  return 1&lt;br /&gt;fi &lt;br /&gt;&lt;br /&gt;if [[ ! "$manpage" ]]; then     # turn "pman ls" into "pman 1 ls"&lt;br /&gt;   manpage="$section"         # if $manpage is an empty string because there has been no "$2" then $manpage is set to "$section" and ...&lt;br /&gt;   section="1"                # ... $section is set to "1"&lt;br /&gt;fi                            &lt;br /&gt;&lt;br /&gt;if [[ ! -f "`man ${section} -W ${manpage} 2&gt;/dev/null`" ]]; then&lt;br /&gt;   echo "No such man page: man ${section} ${manpage}"&lt;br /&gt;   return 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [[ ! -d $mandir ]]; then&lt;br /&gt;   mkdir -p $mandir&lt;br /&gt;   chmod 1777 $mandir&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;manfile="${mandir}/${manpage}(${section}).pdf"&lt;br /&gt;&lt;br /&gt;if [[ -f "$manfile" ]]; then&lt;br /&gt;   open "$manfile"&lt;br /&gt;else&lt;br /&gt;   man $section -t $manpage 2&gt;/dev/null | pstopdf -i -o "$manfile" 2&gt;/dev/null&lt;br /&gt;   chmod 1755 "$manfile"&lt;br /&gt;   # hide file extension .pdf&lt;br /&gt;   if [[ -f /Developer/Tools/SetFile ]]; then /Developer/Tools/SetFile -a E "$manfile"; fi&lt;br /&gt;   open "$manfile"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;return 0&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Sat, 07 Jul 2007 10:54:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4274</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Setting up Ruby On Rails with PostgreSQL on Mac OS X 10.4.9</title>
      <link>http://snippets.dzone.com/posts/show/4187</link>
      <description>This is a modified version of the &lt;a href="http://wiki.rubyonrails.org/rails/pages/Tutorial"&gt;Ruby on Rails Tutorial&lt;/a&gt; (&lt;a href="http://wiki.rubyonrails.org/rails/pages/TutorialStepOne"&gt;TutorialStepOne&lt;/a&gt;, &lt;a href="http://wiki.rubyonrails.org/rails/pages/TutorialStepOnePostgresql"&gt;TutorialStepOnePostgresql&lt;/a&gt;, ...).&lt;br /&gt;&lt;br /&gt;Log in to an admin user account and, if necessary, fix your command search path in $HOME/.bash_profile, $HOME/.bash_login or $HOME/.profile to include "/usr/local" and "/usr/local/sbin" (cf. &lt;a href="http://hivelogic.com/narrative/articles/using_usr_local"&gt;Using /usr/local &gt; Set The Path&lt;/a&gt;; echo $PATH | tr ":" "\n"). If there are no such files, just create them: touch $HOME/.bash_login &amp;&amp; touch $HOME/.bashrc (ls -a | grep \.bash).&lt;br /&gt;&lt;br /&gt;To avoid RubyGems loading issues it's no bad idea to add  &lt;a href="http://rubygems.org/read/chapter/3"&gt;export RUBYOPT=rubygems&lt;/a&gt;  to your $HOME/.bash_login file as well.&lt;br /&gt;&lt;br /&gt;If you want your system path changes to take effect not only for you you can modify the global system path settings in the systemwide initialization files /private/etc/profile and /private/etc/bashrc accordingly.&lt;br /&gt;&lt;br /&gt;To fix the paths of installed manual pages add the lines "MANPATH /usr/local/share/man" and "MANPATH /usr/local/man" to sudo nano +45 /usr/share/misc/man.conf (man -w | tr ":" "\n").&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(USE THE FOLLOWING AT YOUR OWN RISK!)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;REQUIREMENTS:&lt;br /&gt;&lt;br /&gt;I.     &lt;a href="http://developer.apple.com/tools/xcode/index.html"&gt;Xcode&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;II.    PostgreSQL Database Server&lt;br /&gt;&lt;br /&gt;Install this &lt;a href="http://www.entropy.ch/software/macosx/postgresql/"&gt;PostgreSQL Database Server&lt;/a&gt; package.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# test after installation&lt;br /&gt;which psql     # /usr/local/bin/psql&lt;br /&gt;psql --version     # psql (PostgreSQL) 8.2.3, contains support for command-line editing&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Alternative installation: &lt;a href="http://brilliantcorners.org/node/84"&gt;Getting PostgreSQL running for Rails on a Mac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;III.   Ruby 1.8.6, Ruby On Rails 1.2.3 &amp; Mongrel 1.0.1&lt;br /&gt;&lt;br /&gt;&lt;a href="http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx"&gt;Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To install both Mongrel &amp; Mongrel Cluster use: sudo gem install -y mongrel mongrel_cluster (cf. &lt;a href="http://mongrel.rubyforge.org/docs/mongrel_cluster.html"&gt;Using Mongrel Cluster&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# test after installation&lt;br /&gt;ruby -v     # ruby 1.8.6&lt;br /&gt;rails -v     # Rails 1.2.3&lt;br /&gt;gem list     # ... mongrel (1.0.1) ...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IV. &lt;a href="http://rubyforge.org/projects/ruby-postgres/"&gt;ruby-postgres&lt;/a&gt; 0.7.1&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo gem install -y ruby-postgres&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As an alternative you may try &lt;a href="http://www.dotrb.com/2007/3/25/ruby-on-rails-installer-script-for-mac-osx"&gt;Ruby on rails installer script for Mac OSX&lt;/a&gt; or choose to install via MacPorts as described in &lt;a href="http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition"&gt;Installing Ruby on Rails and PostgreSQL on OS X, Second Edition&lt;/a&gt; or &lt;a href="http://blog.nanorails.com/articles/2006/10/17/installing-rails-on-mac-os-x-tiger-10-4-8"&gt;Installing Rails on Mac OS X Tiger (10.4.8)&lt;/a&gt;. However, you then may have to change your system paths mentioned above &lt;a href="http://www.railsontherun.com/2007/5/9/installing-postgresql-on-mac"&gt;accordingly&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. create a database server&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;# first create a directory called PostgreSQL-db on your Desktop&lt;br /&gt;mkdir -p $HOME/Desktop/PostgreSQL-db&lt;br /&gt;&lt;br /&gt;# create a new db server called railsdb&lt;br /&gt;/usr/local/bin/initdb -E UTF8 -D $HOME/Desktop/PostgreSQL-db/railsdb&lt;br /&gt;&lt;br /&gt;# START DB SERVER&lt;br /&gt;dir="$HOME/Desktop/PostgreSQL-db"; /usr/local/bin/pg_ctl -D $dir/railsdb -l $dir/railsdb/postgres.log start&lt;br /&gt;&lt;br /&gt;# STOP DB SERVER&lt;br /&gt;#dir="$HOME/Desktop/PostgreSQL-db"; /usr/local/bin/pg_ctl -D $dir/railsdb -l $dir/railsdb/postgres.log stop -m smart&lt;br /&gt;&lt;br /&gt;# check&lt;br /&gt;cat $HOME/Desktop/PostgreSQL-db/railsdb/pg_hba.conf&lt;br /&gt;&lt;br /&gt;   ...&lt;br /&gt;   # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD&lt;br /&gt;&lt;br /&gt;   # "local" is for Unix domain socket connections only&lt;br /&gt;   local   all         all                               trust&lt;br /&gt;   # IPv4 local connections:&lt;br /&gt;   host    all         all         127.0.0.1/32          trust&lt;br /&gt;   # IPv6 local connections:&lt;br /&gt;   host    all         all         ::1/128               trust&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;2. create PostgreSQL database&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;createdb `whoami`_development&lt;br /&gt;#dropdb `whoami`_development&lt;br /&gt;&lt;br /&gt;createdb `whoami`_test&lt;br /&gt;#dropdb `whoami`_test&lt;br /&gt;&lt;br /&gt;#createdb `whoami`_production&lt;br /&gt;#dropdb `whoami`_production&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;3. set up your Rails project&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;cd $HOME/Desktop/RubyOnRails-projects&lt;br /&gt;rails -d postgresql `whoami`&lt;br /&gt;cd `whoami`&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;4. edit /config/database.yml&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;open -e $HOME/Desktop/RubyOnRails-projects/`whoami`/config/database.yml&lt;br /&gt;&lt;br /&gt;# just uncomment the following line&lt;br /&gt;#encoding: UTF8 &lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;5. make Rails &amp; PostgreSQL work together&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;cd $HOME/Desktop/RubyOnRails-projects/`whoami`&lt;br /&gt;&lt;br /&gt;ruby script/generate migration People&lt;br /&gt;&lt;br /&gt;# edit /db/migrate/001_people.rb&lt;br /&gt;# cf. http://wiki.rubyonrails.org/rails/pages/TutorialStepOneMigrations&lt;br /&gt;&lt;br /&gt;open -e $HOME/Desktop/RubyOnRails-projects/`whoami`/db/migrate/001_people.rb&lt;br /&gt;&lt;br /&gt; class People &lt; ActiveRecord::Migration&lt;br /&gt;&lt;br /&gt;    def self.up&lt;br /&gt;      create_table :people do |table|&lt;br /&gt;      # note that "id" is added implicitly, by default&lt;br /&gt;        table.column :name, :string&lt;br /&gt;        table.column :street1, :string&lt;br /&gt;        table.column :street2, :string&lt;br /&gt;        table.column :city, :string&lt;br /&gt;        table.column :state, :string&lt;br /&gt;        table.column :zip, :string&lt;br /&gt;     end&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    def self.down&lt;br /&gt;      drop_table :people &lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;rake db:migrate&lt;br /&gt;&lt;br /&gt;ruby script/generate model Person  &lt;br /&gt;&lt;br /&gt;#open -e $HOME/Desktop/RubyOnRails-projects/`whoami`/app/models/person.rb  # file will be explained below&lt;br /&gt;&lt;br /&gt;ruby script/console&lt;br /&gt;&lt;br /&gt;&gt;&gt; ...&lt;br /&gt;        entry = Person.new&lt;br /&gt;        entry.name = "Name" &lt;br /&gt;        entry.street1 = "123 Somwhere" &lt;br /&gt;        entry.street2 = "" &lt;br /&gt;        entry.city = "Smallville" &lt;br /&gt;        entry.state = "KS" &lt;br /&gt;        entry.zip = "123456" &lt;br /&gt;        entry.save&lt;br /&gt;        exit&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# check newly created db table&lt;br /&gt;&lt;br /&gt;psql `whoami`_development&lt;br /&gt;SELECT * FROM people;&lt;br /&gt;\q&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# test&lt;br /&gt;rake      # ... 0 failures, 0 errors&lt;br /&gt;&lt;br /&gt;# create new controller&lt;br /&gt;ruby script/generate controller People list view new edit&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# edit /app/controllers/people_controller.rb&lt;br /&gt;open -e $HOME/Desktop/RubyOnRails-projects/`whoami`/app/controllers/people_controller.rb&lt;br /&gt;&lt;br /&gt;  def view&lt;br /&gt;   @person = Person.find(1)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# edit /app/views/people/view.rhtml&lt;br /&gt;open -e $HOME/Desktop/RubyOnRails-projects/`whoami`/app/views/people/view.rhtml&lt;br /&gt;&lt;br /&gt;# copy &amp; paste &amp; uncomment the following lines&lt;br /&gt;&lt;br /&gt;#&lt;html&gt;&lt;br /&gt;#  &lt;body&gt;&lt;br /&gt;#    &lt;h1&gt;People#view&lt;/h1&gt;&lt;br /&gt;#    &lt;p&gt;This page will display one person.&lt;/p&gt;&lt;br /&gt;#    &lt;p&gt;&lt;br /&gt;#    &lt;%= @person.name %&gt;&lt;br /&gt;&lt;br /&gt;#    &lt;%= @person.street1 %&gt;&lt;br /&gt;&lt;br /&gt;#    &lt;%= @person.street2 %&gt;&lt;br /&gt;&lt;br /&gt;#    &lt;%= @person.city %&gt;&lt;br /&gt;&lt;br /&gt;#    &lt;%= @person.state %&gt;&lt;br /&gt;&lt;br /&gt;#    &lt;%= @person.zip %&gt;&lt;br /&gt;&lt;br /&gt;#    &lt;/p&gt;&lt;br /&gt;#  &lt;/body&gt;&lt;br /&gt;#&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# the file /app/models/person.rb explained (see above)&lt;br /&gt;# open -e $HOME/Desktop/RubyOnRails-projects/`whoami`/app/models/person.rb&lt;br /&gt;&lt;br /&gt;# class Person &lt; ActiveRecord::Base&lt;br /&gt;# end&lt;br /&gt;&lt;br /&gt;# How does this know to map to the people table we created? ActiveRecord pluralizes the class name and looks for that &lt;br /&gt;# table in the database. This doesn&#8217;t just mean adding an &#8217;s&#8217;. Irregular plural forms are also handled, so Rails knows &lt;br /&gt;# that the plural of &#8216;person&#8217; is &#8216;people&#8217;. The rules for how it does this are described in the documentation&lt;br /&gt;# (see http://wiki.rubyonrails.org/rails/pages/TutorialStepSix).&lt;br /&gt;&lt;br /&gt;# test&lt;br /&gt;rake&lt;br /&gt;&lt;br /&gt;# start your Rails app&lt;br /&gt;cd $HOME/Desktop/RubyOnRails-projects/`whoami`&lt;br /&gt;&lt;br /&gt;ruby script/server&lt;br /&gt;#ruby script/server --environment=development&lt;br /&gt;&lt;br /&gt;# open a second shell window and go to ...  &lt;br /&gt;open -a Safari http://localhost:3000/people/view&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Thu, 21 Jun 2007 21:25:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4187</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Mac OS X launchd plist to run PHP fcgi</title>
      <link>http://snippets.dzone.com/posts/show/4115</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;br /&gt;&lt;!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN&lt;br /&gt;http://www.apple.com/DTDs/PropertyList-1.0.dtd &gt;&lt;br /&gt;&lt;plist version='1.0'&gt;&lt;br /&gt;	&lt;dict&gt;&lt;br /&gt;	&lt;key&gt;Label&lt;/key&gt;&lt;string&gt;com.automatthew.php&lt;/string&gt;&lt;br /&gt;	&lt;key&gt;ProgramArguments&lt;/key&gt;&lt;br /&gt;	&lt;array&gt;&lt;br /&gt;	        &lt;string&gt;/opt/php/bin/php&lt;/string&gt;&lt;br /&gt;	        &lt;string&gt;-b 127.0.0.1:9000&lt;/string&gt;&lt;br /&gt;	        &lt;string&gt;-q&lt;/string&gt;&lt;br /&gt;	&lt;/array&gt;&lt;br /&gt;	&lt;key&gt;EnvironmentVariables&lt;/key&gt;&lt;br /&gt;	&lt;dict&gt;&lt;br /&gt;	        &lt;key&gt;PHP_FCGI_CHILDREN&lt;/key&gt;&lt;br /&gt;	        &lt;string&gt;4&lt;/string&gt;&lt;br /&gt;	&lt;/dict&gt;&lt;br /&gt;	&lt;key&gt;Debug&lt;/key&gt;&lt;false/&gt;&lt;br /&gt;	&lt;key&gt;Disabled&lt;/key&gt;&lt;false/&gt;&lt;br /&gt;	&lt;key&gt;OnDemand&lt;/key&gt;&lt;false/&gt;&lt;br /&gt;	&lt;key&gt;RunAtLoad&lt;/key&gt;&lt;false/&gt;&lt;br /&gt;&lt;/dict&gt;&lt;br /&gt;&lt;/plist&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 07 Jun 2007 19:51:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4115</guid>
      <author>automatthew (Matthew King)</author>
    </item>
    <item>
      <title>Command-line progress indicators</title>
      <link>http://snippets.dzone.com/posts/show/3760</link>
      <description>... just some proof-of-concept snippets ... &lt;br /&gt;&lt;br /&gt;inspired by:  http://www.ruby-forum.com/topic/87404&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;# move cursor to beginning of line&lt;br /&gt;cr = "\r"           &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# ANSI escape code to clear line from cursor to end of line&lt;br /&gt;# "\e" is an alternative to "\033"&lt;br /&gt;# cf. http://en.wikipedia.org/wiki/ANSI_escape_code&lt;br /&gt;&lt;br /&gt;clear = "\e[0K"     &lt;br /&gt;&lt;br /&gt;# reset lines&lt;br /&gt;reset = cr + clear&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#-------------------------------- Example 1 --------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(1..100).each do |i| &lt;br /&gt;  print "#{reset}#{i}%"&lt;br /&gt;  sleep(0.08)&lt;br /&gt;  $stdout.flush&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;print "#{reset}"     # clear current line&lt;br /&gt;&lt;br /&gt;$stdout.flush&lt;br /&gt;puts "done"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#-------------------------------- Example 2 --------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;chars = [ "|", "/", "-", "\\" ]&lt;br /&gt;&lt;br /&gt;# 7 turns on reverse video mode, 31 red , ...&lt;br /&gt;n = 31&lt;br /&gt;&lt;br /&gt;str = "#{reset}\e[#{n};1m"   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(1..100).each do |i| &lt;br /&gt;&lt;br /&gt;   case i&lt;br /&gt;      when   0..10    then print "#{str}#{chars[0]}"&lt;br /&gt;      when  10..20    then print "#{str}#{chars[1]}"&lt;br /&gt;      when  20..30    then print "#{str}#{chars[2]}"&lt;br /&gt;      when  30..40    then print "#{str}#{chars[3]}"&lt;br /&gt;      when  40..50    then print "#{str}#{chars[0]}"&lt;br /&gt;      when  50..60    then print "#{str}#{chars[1]}"&lt;br /&gt;      when  60..70    then print "#{str}#{chars[2]}"&lt;br /&gt;      when  70..80    then print "#{str}#{chars[3]}"&lt;br /&gt;      when  80..90    then print "#{str}#{chars[0]}"&lt;br /&gt;      when  90..100   then print "#{str}#{chars[1]}"&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;   sleep(0.1)&lt;br /&gt;   $stdout.flush&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;print "\e[0m"&lt;br /&gt;print "#{reset}" &lt;br /&gt;&lt;br /&gt;$stdout.flush&lt;br /&gt;puts "done"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#-------------------------------- Example 3 --------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MAX = 80 &lt;br /&gt;&lt;br /&gt;$stdout.sync = true     # alternative to $stdout.flush below&lt;br /&gt;&lt;br /&gt;10.times do&lt;br /&gt;   foo_string = Time.now.to_s&lt;br /&gt;   s = foo_string[0..MAX].center(MAX)   # or rjust or ljust &lt;br /&gt;   print cr + s &lt;br /&gt;   #$stdout.flush &lt;br /&gt;   sleep(1.1)&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;print "\e[0m" &lt;br /&gt;print "#{reset}" &lt;br /&gt;&lt;br /&gt;$stdout.flush&lt;br /&gt;puts "done"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 04 Apr 2007 18:22:50 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3760</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Optimize Aperture database</title>
      <link>http://snippets.dzone.com/posts/show/3630</link>
      <description>&lt;code&gt;&lt;br /&gt;sqlite3 Pictures/Aperture\ Library.aplibrary/Aperture.aplib/Library.apdb vacuum&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 05 Mar 2007 14:43:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3630</guid>
      <author>willcodeforfoo ()</author>
    </item>
  </channel>
</rss>
