<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alastair&#039;s Axioms &#187; Uncategorized</title>
	<atom:link href="http://blog.alastairdawson.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.alastairdawson.com</link>
	<description>Let us toast your non-idiocy</description>
	<lastBuildDate>Thu, 11 Aug 2011 23:13:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Datamapper is remixable example</title>
		<link>http://blog.alastairdawson.com/2010/07/29/a-datamapper-is-remixable-example/</link>
		<comments>http://blog.alastairdawson.com/2010/07/29/a-datamapper-is-remixable-example/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 01:10:23 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[dm-is-remixable]]></category>
		<category><![CDATA[remixable]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://blog.alastairdawson.com/?p=219</guid>
		<description><![CDATA[I struggled a bit this afternoon getting Datamapper&#8217;s dm-is-remixable plug-in as there aren&#8217;t too many posts out there and some are out of date. Hopefully this quick overview will spare you my pain  
Many sites allow you to comment on blog posts, images, videos, status, etc. having one comments table with post_id, image_id, etc. [...]]]></description>
			<content:encoded><![CDATA[<p>I struggled a bit this afternoon getting <a href="http://datamapper.org/">Datamapper&#8217;s</a> dm-is-remixable plug-in as there aren&#8217;t too many posts out there and some are out of date. Hopefully this quick overview will spare you my pain <img src='http://blog.alastairdawson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Many sites allow you to comment on blog posts, images, videos, status, etc. having one comments table with post_id, image_id, etc. as with a One-to-Many relationship leads to a giant table of unrelated (other than by user_id) data. In my opinion it&#8217;s better to have a table for each e.g. post_comments, image_comments, etc. Enter dm-is-remixable.</p>
<p><strong>Step 1: Install</strong></p>
<p>We&#8217;ll install dm-is-remixable and friends. Open up a terminal and enter:</p>
<pre>
sudo gem install do_sqlite3
sudo gem install datamapper
sudo gem install dm-migrations
sudo gem install dm-is-remixable
</pre>
<p><strong>Step 2: Setup</strong></p>
<p>Create a new file called remixable.rb we&#8217;ll user this file from now on. First enter the required gems and set Datamapper&#8217;s log and sqlite file.</p>
<pre>
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-is-remixable'

# setup

DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/remixable.db")
</pre>
<p><strong>Step 3 Define the Models</strong></p>
<p>We&#8217;ll create four models, one module and three classes. User, Post, and Image are classes, and Comment will be a module. The relationships are a user has many posts and images, posts and images belong to a user, nothing new yet, and post and image remix many comments for a user. What? This is the same as saying a post has many comments and said comment(s) belong to a user. </p>
<pre>
# module and classes

module Comment
  include DataMapper::Resource

  property :id, Serial
  property :comment, Text

  is :remixable
end

class User
  include DataMapper::Resource

  property :id, Serial
  property :username, String

  has n, :images
  has n, :posts
end

class Post
  include DataMapper::Resource

  property :id, Serial
  property :title, String
  property :body, Text

  belongs_to :user
  remix n, :comments, :for => 'User'
end

class Image
  include DataMapper::Resource

  property :id, Serial
  property :path, String

  belongs_to :user
  remix n, :comments, :for => 'User'
end
</pre>
<p><strong>Step 4: Migrate</strong></p>
<p>Next we&#8217;ll finalize our models and run auto_migrate to create the tables. During this step Datamapper, via is remixable, will generate two anonymous model classes PostComment and ImageComment. Five tables will be created users, posts, images, post_comments, and image_comments.</p>
<pre>
# lock and load

DataMapper.finalize
DataMapper.auto_migrate!
</pre>
<p><strong>Step 5: Do Something</strong></p>
<p>The last step is to create some dummy data to test out our models. We&#8217;ll create two users &#8216;foo&#8217; and &#8216;funk&#8217;, foo will create post and &#8216;image&#8217; and &#8216;funk&#8217; will comment on them. The last two lines show how to access post and image comments for a user.</p>
<pre>
# go!

foo = User.create(
  :username => "foo"
)

funk = User.create(
  :username => "funk"
)

post = Post.create(
  :user_id => foo.id,
  :title => "My great post",
  :body => "This is my great post"
)

post_comment = PostComment.create(
  :user_id => funk.id,
  :post_id => post.id,
  :comment => "ballz I say!"
)

image = Image.create(
  :user_id => foo.id,
  :path => "/some/image/path"
)

image_comment = ImageComment.create(
  :user_id => funk.id,
  :image_id => image.id,
  :comment => "you look funny!"
)

puts funk.post_comments[0].comment
puts funk.image_comments[0].comment
</pre>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2010/07/29/a-datamapper-is-remixable-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting Netbeans 6.9 to work on OS X 10.5.8</title>
		<link>http://blog.alastairdawson.com/2010/07/15/getting-netbeans-6-9-to-work-on-os-x-10-5-8/</link>
		<comments>http://blog.alastairdawson.com/2010/07/15/getting-netbeans-6-9-to-work-on-os-x-10-5-8/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 20:34:02 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.alastairdawson.com/?p=193</guid>
		<description><![CDATA[
After downloading and installing Netbeans 6.9 I launched the app. It bounced a couple of times in my dock as dreams of exciting new features danced in my head. Then&#8230; nothing, well not quite nothing, I received a message informing me that:
&#8220;Java 6 Standard Edition or newer required. Cannot run on older versions of Java [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-195" title="netbeans69osxerror" src="http://blog.alastairdawson.com/wp-content/uploads/2010/07/netbeans69osxerror.png" alt="netbeans69osxerror" width="616" height="229" /></p>
<p>After downloading and installing Netbeans 6.9 I launched the app. It bounced a couple of times in my dock as dreams of exciting new features danced in my head. Then&#8230; nothing, well not quite nothing, I received a message informing me that:</p>
<p>&#8220;Java 6 Standard Edition or newer required. Cannot run on older versions of Java than Java 6 Standard Edition. Please install Java 6 Standard Edition or newer or use &#8211;jdkhome switch to point to its installation directory.&#8221;</p>
<p>How to solve this issue:</p>
<p><strong>Step 1. Figure out which version of Java you have </strong></p>
<p>Open Terminal.app and enter:</p>
<pre>java -version</pre>
<p>You&#8217;ll most likely see the following:</p>
<pre>java version "1.5.0_24"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_24-b02-357-9M3165)
Java HotSpot(TM) Client VM (build 1.5.0_24-149, mixed mode, sharing)</pre>
<p>Obviously this is the wrong Java version since Netbeans is asking for Java 6 (aka Java 1.6).</p>
<p><strong>Step 2. Get Java 1.6</strong></p>
<p>However if you head over to Oracle you&#8217;ll find downloads for Linux and Windows but none for Mac. Why has the mighty Oracle deemed you unworthy of the latest Java? </p>
<p>Because you already have it! Your Mac is just not setup to use it. </p>
<p>Go Back to the Terminal and enter the following:</p>
<pre>cd /System/Library/Frameworks/JavaVM.framework/Versions; ls;</pre>
<p>You&#8217;ll get a list of all the Java versions available.</p>
<pre>1.3		1.4		1.4.2		1.5.0		1.6.0		Current
1.3.1		1.4.1		1.5		1.6		A		CurrentJDK</pre>
<p><strong>Step 3. Configure Netbeans</strong></p>
<p>The hint to get Netbeans working is in the error message; &#8220;or use &#8211;jdkhome switch to point to its installation directory&#8221;. </p>
<p>In the Finder browse to the NetBeans 6.9.app (in Applications/NetBeans/). Apps on OS X are really just packages so you can explore and edit their contents. Right-click (or control-click) on the app and select &#8216;Show Package Contents&#8217; this will open a new Finder window. Then browse to Contents/Resources/NetBeans/etc and open &#8216;netbeans.conf&#8217; in a text editor. Uncomment (remove the pound sign from) the line that starts with &#8216;#netbeans_jdkhome&#8217; and set it to point to your Java 1.6 home as below:</p>
<pre>netbeans_jdkhome="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"</pre>
<p>Save the file.</p>
<p>That&#8217;s it!</p>
<p>Try launching the NetBeans 6.9 app again, it should now work.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2010/07/15/getting-netbeans-6-9-to-work-on-os-x-10-5-8/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
	</channel>
</rss>

