<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>odwks</title>
	<atom:link href="http://odwks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://odwks.com</link>
	<description>:  old dudes who know smalltalk</description>
	<pubDate>Wed, 01 Oct 2008 08:37:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>postgres install on OS X</title>
		<link>http://odwks.com/2008/10/postgresql-install-on-os-x/</link>
		<comments>http://odwks.com/2008/10/postgresql-install-on-os-x/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 07:49:05 +0000</pubDate>
		<dc:creator>jhancock</dc:creator>
		
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://odwks.com/?p=18</guid>
		<description><![CDATA[I use postgres 8.3.x for ShellShadow.  My production and staging servers are linux but my dev and testing is done on OS X 10.5.x.  There exist &#8220;one-click installers&#8221; for postgres on OS X.  They are good and well worth using if that&#8217;s what you need.  I need finer control and like to use an install [...]]]></description>
			<content:encoded><![CDATA[<p>I use postgres 8.3.x for <a href="http://shellshadow.com" onclick="javascript:pageTracker._trackPageview ('/outbound/shellshadow.com');">ShellShadow</a>.  My production and staging servers are linux but my dev and testing is done on OS X 10.5.x.  There exist <a href="http://www.postgresql.org/download/macosx" onclick="javascript:pageTracker._trackPageview ('/outbound/www.postgresql.org');">&#8220;one-click installers&#8221;</a> for postgres on OS X.  They are good and well worth using if that&#8217;s what you need.  I need finer control and like to use an install as close to the same as what&#8217;s on my production machine.  So I install from source.  PostgreSQL installs quite easily from source but under OS X there are some little tricks that make your install cleaner and more like the production system.</p>
<p>Here is my recipe, tested under OS X 10.5.5 with postgres 8.3.4:</p>
<p><strong>Find an unused Group and User IDs.</strong> My system has two &#8220;login users&#8221;.  I want to add another user and need to find a number not in use.  The trick is to create a new user that does not show up on the OS X login dialog.   I found tips from here: http://macosx.com/forums/mac-os-x-system-mac-software/297377-add-user-can-not-seen.html<br />
<code><br />
&gt; sudo dscl . -list /Groups PrimaryGroupID<br />
&gt; sudo dscl . -list /Users UniqueID<br />
</code><br />
On my system, ID 503 is not in use, I&#8217;ll use this for my postgres Group and User IDs.  Note: OS X should give you an error on the following commands if you screw up and pick an ID already in use.</p>
<p><strong>Create OS X Group and User for postgres </strong>using ID 503 (substitute a different ID if this is taken):<br />
<code><br />
&gt; sudo dscl . create /Groups/postgres<br />
&gt; sudo dscl . create /Groups/postgres PrimaryGroupID 503<br />
&gt; sudo dscl . create /Groups/postgres RealName 'Postgres Admin Group'<br />
&gt; sudo dscl . create /Users/postgres<br />
&gt; sudo dscl . create /Users/postgres UniqueID 503<br />
&gt; sudo dscl . create /Users/postgres PrimaryGroupID 503<br />
# not sure if this next command is necessary.<br />
&gt; sudo dscl . create /Users/postgres NFSHomeDirectory /usr/local/pgsql<br />
&gt; sudo dscl . create /Users/postgres Password '*'<br />
&gt; sudo dscl . create /Users/postgres UserShell /bin/bash<br />
&gt; sudo dscl . create /Users/postgres RealName 'Postgres Admin User'</code></p>
<p><strong>Install postgres.</strong>  Download latest source from http://www.postgresql.org/ftp/source/ We&#8217;ll assume postgresql-8.3.4.tar.gz for this example.<br />
<code><br />
&gt; tar zxf postgresql-8.3.4.tar.gz<br />
# check your umask.  0002 or 0022 is good.<br />
&gt; umask<br />
&gt; cd postgresql-8.3.4<br />
&gt; ./configure<br />
&gt; make<br />
&gt; sudo make install<br />
&gt; sudo mkdir /usr/local/pgsql/data<br />
&gt; sudo chown postgres:postgres /usr/local/pgsql/data<br />
# switch to postgres user to initialize the database<br />
&gt; sudo su postgres<br />
&gt; /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data<br />
&gt; exit<br />
# setup the logs directory<br />
&gt; sudo mkdir /usr/local/pgsql/data/logs<br />
&gt; sudo chown postgres:postgres /usr/local/pgsql/data/logs<br />
&gt; sudo chmod 700 /usr/local/pgsql/data/logs<br />
# setup OS X launch script<br />
# paths assume you are still in the postgresql-8.3.4 source root<br />
&gt; cd contrib/start-scripts/osx<br />
&gt; sudo /bin/sh ./install.sh<br />
# to keep postgres from starting at OS X system start, edit /etc/hostconfig file:<br />
# change  POSTGRESQL=-YES-  =&gt;  POSTGRESQL=-NO-<br />
# to manually stop postgres<br />
&gt; sudo /Library/StartupItems/PostgreSQL/PostgreSQL stop<br />
# to manually start postgres<br />
&gt; sudo /Library/StartupItems/PostgreSQL/PostgreSQL start<br />
# add /usr/local/pgsql/bin to your PATH<br />
# in my ~/.bash_profile I have a line near the top which I changed to<br />
# PATH=$HOME/bin:/usr/local/pgsql/bin:$PATH:<br />
# after PATH change, exit shell and reopen or re-source .bash_profile<br />
# test if you can connect<br />
&gt; psql -Upostgres<br />
# type \q to quit</code></p>
<p><strong>Install pgcrypto.</strong>  Basic digest and crypto functions are not in the default compile.  You must install them separately.  Its best to do this now as the install requires the config options created from the core install above.<br />
<code><br />
# from postgresql-8.3.4/contrib/pgcrypto<br />
&gt; make<br />
&gt; sudo make install<br />
# The above install creates </code><code>/usr/local/pgsql/share/contrib/pgcrypto.sql which must be imported</code><code> to each schema (YOUR_DB_NAME) where the functions are used.<br />
&gt; psql -Upostgres -d <em>YOUR_DB_NAME</em> -f /usr/local/pgsql/share/contrib/pgcrypto.sql </code></p>
]]></content:encoded>
			<wfw:commentRss>http://odwks.com/2008/10/postgresql-install-on-os-x/feed/</wfw:commentRss>
		</item>
		<item>
		<title>migrating to datamapper 0.9 - unique indexes</title>
		<link>http://odwks.com/2008/06/migrating-to-datamapper-09-unique-indexes/</link>
		<comments>http://odwks.com/2008/06/migrating-to-datamapper-09-unique-indexes/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 08:52:30 +0000</pubDate>
		<dc:creator>jhancock</dc:creator>
		
		<category><![CDATA[datamapper]]></category>

		<guid isPermaLink="false">http://odwks.com/?p=14</guid>
		<description><![CDATA[This is a first post on migrating from datamapper 0.2.5 to 0.9.  0.9 is a complete rewrite of datamapper so careful attention needs to be applied for this migration.  ShellShadow is in production with 0.2.5 and I hope to get a new release out on 0.9 very soon so I&#8217;ll be posting my [...]]]></description>
			<content:encoded><![CDATA[<p>This is a first post on migrating from <a href="http://datamapper.org" onclick="javascript:pageTracker._trackPageview ('/outbound/datamapper.org');">datamapper</a> 0.2.5 to 0.9.  0.9 is a complete rewrite of datamapper so careful attention needs to be applied for this migration.  <a href="http://shellshadow.com" onclick="javascript:pageTracker._trackPageview ('/outbound/shellshadow.com');">ShellShadow</a> is in production with 0.2.5 and I hope to get a new release out on 0.9 very soon so I&#8217;ll be posting my experiences as I go.</p>
<p>The first thing I have encountered is a key difference in defining unique indexes.</p>
<p>In 0.2.5 ( or 0.3) you would write something like this:<br />
<code><br />
class User &lt; DataMapper::Base<br />
property :email, String, :index =&gt; :unique<br />
property :display_name, String, :index =&gt; :unique<br />
</code><br />
which would produce SQL indexes (for postgres) as:<br />
<code><br />
Indexes:<br />
"users_pkey" PRIMARY KEY, btree (id)<br />
"users_display_name_key" UNIQUE, btree (display_name)<br />
"users_email_key" UNIQUE, btree (email)<br />
"users_display_name_index" btree (display_name)<br />
"users_email_index" btree (email)<br />
</code></p>
<p>doing a fairly straightforward conversion to datamapper 0.9 yields the following:<br />
<code><br />
class User<br />
include DataMapper::Resource<br />
property :id, Integer, :serial =&gt; true<br />
property :email, String, :index =&gt; :unique<br />
property :display_name, String, :index =&gt; :unique<br />
</code><br />
which generate these SQL indexes (postgres):<br />
<code><br />
Indexes:<br />
"users_pkey" PRIMARY KEY, btree (id)<br />
"index_users_unique" btree (email, display_name)<br />
</code></p>
<p style="text-align: left;">This creates a single unique index on the combined fields email and display_name; not what I want.  I assume this is quite possibly an intended effect as this is how combined key fields gets handled in the new dm 0.9.  After a few minutes looking through the very clean datamapper 0.9 source, I find there a constraint type called <code>unique_index</code>.  When I use this as follows:<br />
<code><br />
class User<br />
include DataMapper::Resource<br />
property :id, Integer, :serial =&gt; true<br />
property :email, String, :unique_index =&gt; true<br />
property :display_name, String, :unique_index =&gt; true<br />
</code><br />
I get indexes generated as:<br />
<code><br />
Indexes:<br />
"users_pkey" PRIMARY KEY, btree (id)<br />
"unique_index_users_display_name" UNIQUE, btree (display_name)<br />
"unique_index_users_email" UNIQUE, btree (email)<br />
</code></p>
<p>much better!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://odwks.com/2008/06/migrating-to-datamapper-09-unique-indexes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>monkeypatching merb</title>
		<link>http://odwks.com/2008/04/monkeypatching-merb/</link>
		<comments>http://odwks.com/2008/04/monkeypatching-merb/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 08:50:53 +0000</pubDate>
		<dc:creator>jhancock</dc:creator>
		
		<category><![CDATA[datamapper]]></category>

		<category><![CDATA[do_postgres]]></category>

		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[shellshadow]]></category>

		<guid isPermaLink="false">http://odwks.com/?p=11</guid>
		<description><![CDATA[If you never heard of merb, stop reading this and go check it out!!!
One of things you will encounter when using the coolest and latest technologies is that they might contain bugs ;).  It is what we encountered in using datamapper 0.2.5 and do_postgres 0.2.3 in our merb 0.9.2 development stack for ShellShadow.
Here&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>If you never heard of <a href="http://merbivore.com/" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/merbivore.com');">merb</a>, stop reading this and go check it out!!!</p>
<p>One of things you will encounter when using the coolest and latest technologies is that they might contain bugs ;).  It is what we encountered in using <a href="http://datamapper.org/" onclick="javascript:pageTracker._trackPageview ('/outbound/datamapper.org');">datamapper</a> 0.2.5 and do_postgres 0.2.3 in our merb 0.9.2 development stack for <a href="http://shellshadow.com" onclick="javascript:pageTracker._trackPageview ('/outbound/shellshadow.com');">ShellShadow</a>.</p>
<p>Here&#8217;s a quick look at how we add our patches into our merb app.</p>
<p>One of nasty bugs existing in datamapper 0.2.5 or 0.3.0 is that it will interpret NULL integer fields from a table as 0.   It was a huge issue for us and had to be patched.</p>
<p style="text-align: left;">Turns out the culprit is not datamapper but in do_postgres.  Many thanks to <a href="http://adam.speaksoutofturn.com" onclick="javascript:pageTracker._trackPageview ('/outbound/adam.speaksoutofturn.com');">Adam French</a> for pointing this out on #datamapper irc channel.</p>
<p style="text-align: left;">The buggy code was in [GEM_PATH]/gems/do_postgres-0.2.3/lib/do_postgres.rb in class Reader &lt; DataObject::Reader method typecast(val, field_type).</p>
<p>The code in questions was:<br />
<code><br />
when "INT2", "INT4", "OID", "TID", "XID", "CID", "INT8"<br />
val.to_i<br />
</code></p>
<p>This should read:<br />
<code><br />
when "INT2", "INT4", "OID", "TID", "XID", "CID", "INT8"<br />
val == "" ? nil : val.to_i<br />
</code></p>
<p>The fix was a one liner but we needed to replace the entire method it was in.</p>
<p>This is how you apply your monkeypatch:</p>
<ol>
<li>Add your patch file under &lt;your_merb_project&gt;/lib.  Lets call it do_postgres_patch.rb.  We put our modified copy of typecast in this file.</li>
<li>In &lt;your_merb_project&gt;/config/init.rb, you&#8217;ll see at the very bottom</li>
<p><code><br />
Merb::BootLoader.after_app_loads do<br />
### Add dependencies here that must load after the application loads:<br />
# dependency "magic_admin" # this gem uses the app's model classes<br />
end<br />
</code><br />
In this block, add:<br />
<code>require 'core_extensions'</code></ol>
<p>That&#8217;s it.  Easy and all patched up!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://odwks.com/2008/04/monkeypatching-merb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ruby debugging with Aptana</title>
		<link>http://odwks.com/2008/04/ruby-debugging-with-aptana/</link>
		<comments>http://odwks.com/2008/04/ruby-debugging-with-aptana/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 08:45:48 +0000</pubDate>
		<dc:creator>jhancock</dc:creator>
		
		<category><![CDATA[aptana]]></category>

		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[shellshadow]]></category>

		<guid isPermaLink="false">http://odwks.com/?p=7</guid>
		<description><![CDATA[I&#8217;m pleased to report that Aptana Studio v1.1 ruby debugging works very well with merb and datamapper.
Last October, I tried every ruby debugger I could find (except the windows-only Sapphire Steele).  At that time, only NetBeans 6 beta had any form of working debugger and for the most part, the command line ruby-debug was [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pleased to report that <a href="http://www.aptana.com/" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/www.aptana.com');">Aptana Studio v1.1</a> ruby debugging works very well with merb and datamapper.</p>
<p>Last October, I tried every ruby debugger I could find (except the windows-only Sapphire Steele).  At that time, only <a href="http://www.netbeans.org/" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/www.netbeans.org');">NetBeans</a> 6 beta had any form of working debugger and for the most part, the command line ruby-debug was a better choice.</p>
<p>We were re-writing <a href="http://shellshadow.com" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/shellshadow.com');">ShellShadow</a> in <a href="http://merbivore.com/" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/merbivore.com');">merb</a> (the old site was Rails).<br />
Now that I&#8217;m exploring merb and <a href="http://datamapper.org/" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/datamapper.org');">datamapper</a> and <a href="http://code.google.com/p/ruby-sequel/" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/code.google.com');">sequel</a>, I find I need a GUI debugger.  Unless you have an internalized mental model of the framework (e.g. you&#8217;re the creator), you won&#8217;t get far fast enough with command line debugging.<br />
Aptana&#8217;s latest release on what was RadRails does the job.</p>
<p>Here are a few things to get you going:</p>
<ol>
<li><a href="http://www.aptana.com/studio/download" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/www.aptana.com');">Download</a> and install Aptana.  This is a multi-step process where you need to install Aptana and then from the intro page, install the RadRails plugin.  There may be updates to Aptana.   Just let eclipse work its magic and update to the latest patches.</li>
<li>install <a href="http://debug-commons.rubyforge.org/index.html" target="_self" onclick="javascript:pageTracker._trackPageview ('/outbound/debug-commons.rubyforge.org');">ruby-debug-ide</a>.<br />
gem install ruby-debug-ide.  You will want to run this as &#8220;sudo gem install ruby-debug-ide&#8221; if you are installing to your global gems setup.</li>
<li style="text-align: left;">On OS X 10.5, I needed to create a link (the following is a one line command)<br />
sudo ln -s /usr/bin/rdebug-ide /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rdebug-ide</li>
<li>Config the ruby debugger in Aptana.  Open the eclipse/aptana preferences dialog from &#8220;Windows-&gt;Preferences&#8230;&#8221;.  In the section &#8220;Ruby&gt;Debugger&#8221;, turn on the checkbox &#8220;Use ruby-debug library.</li>
<li>Setup your app.  I didn&#8217;t create a Rails project.  I create a ruby project (its for merb).  I have my aptana/eclipse workspace outside of my ruby project and simply point the working directory of my project to the right place.  You&#8217;ll want to set your debug setting for this project to run /usr/bin/merb or whatever your app is.    This approach litters my merb project directory with two files: .loadpath and .project.   You&#8217;ll probably want to tell your version control system of choice to ignore these files.</li>
</ol>
<p>Its not perfect, but this seems to be as good as it gets at the moment for a GUI ruby debugger.  Here are a few things of interest:</p>
<ol>
<li>Breakpoint removal is flaky.  We found that sometimes when you turn off a breakpoint, it doesn&#8217;t go away.  We had to edit the code to force aptana/eclipse to refresh itself.</li>
<li>Interactive console isn&#8217;t great.  IRB has a cleaner expereince but the apatana console does work.</li>
<li>Missing ability to eval expressions in the debugger.  This would be a great feature and hopefully it gets added someday.</li>
</ol>
<p>Many thanks to the Aptana RadRails team!!</p>
]]></content:encoded>
			<wfw:commentRss>http://odwks.com/2008/04/ruby-debugging-with-aptana/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
