<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>allskonar - All</title>
  <id>tag:baldur.snitchmedia.com,2008:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://baldur.snitchmedia.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://baldur.snitchmedia.com/" rel="alternate" type="text/html"/>
  <updated>2008-08-22T17:07:04Z</updated>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-08-22:160</id>
    <published>2008-08-22T17:03:00Z</published>
    <updated>2008-08-22T17:07:04Z</updated>
    <category term="handball"/>
    <link href="http://baldur.snitchmedia.com/2008/8/22/what-is-team-handball" rel="alternate" type="text/html"/>
    <title>What is Team handball?</title>
<content type="html">
            &lt;p&gt;&#8220;team&#8221; handball [is played] on a basketball court (but longer) with a volleyball (but smaller) and hockey nets (but taller). It&#8217;s like lacrosse (without sticks) or water-polo (without water).&lt;/p&gt;


	&lt;p&gt;quote from &lt;a href=&quot;http://online.wsj.com/article/SB121936875105662395.html?mod=googlenews_wsj&quot;&gt;wsj&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-31:116</id>
    <published>2008-07-31T01:37:00Z</published>
    <updated>2008-07-31T01:52:26Z</updated>
    <category term="Nothing That Matters"/>
    <category term="hilarity"/>
    <link href="http://baldur.snitchmedia.com/2008/7/31/born-to-code-in-c" rel="alternate" type="text/html"/>
    <title>Born to Code ~ in C</title>
<content type="html">
            &lt;p&gt;This has to be one of the best book covers ever. You really have to focus on all the little details:&lt;/p&gt;


	&lt;p&gt;How the floppy disk is casually resting on the keyboard as if the coder had to leave in a hurry to do some coding else where.
How the books logo is stamped on the back of the leather jacket left behind on the chair.&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://s3.amazonaws.com/blogsnitch/var/www/mephisto/public/assets/2008/7/31/born_to_code_c.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-25:115</id>
    <published>2008-07-25T02:04:00Z</published>
    <updated>2008-07-25T02:09:38Z</updated>
    <category term="Nothing That Matters"/>
    <category term="security"/>
    <link href="http://baldur.snitchmedia.com/2008/7/25/security-ode-to-financial-institution-s-security-requirements" rel="alternate" type="text/html"/>
    <title>Security Ode to Financial Institution's Security Requirements</title>
<content type="html">
            &lt;p&gt;I know I shouldn&#8217;t keep poking fun at some applications since I bet there is plenty people can find where I goofed up &#8230; but this one is truly precious.&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://s3.amazonaws.com/blogsnitch/var/www/mephisto/public/assets/2008/7/25/security.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-14:113</id>
    <published>2008-07-14T02:20:00Z</published>
    <updated>2008-07-14T02:50:58Z</updated>
    <category term=".bash_history"/>
    <category term="Ruby on Rails"/>
    <category term="Tips and Tricks"/>
    <category term="ascii"/>
    <link href="http://baldur.snitchmedia.com/2008/7/14/high-ascii-characters-in-urls" rel="alternate" type="text/html"/>
    <title>High ASCII Characters in Urls</title>
<content type="html">
            &lt;p&gt;When I write web apps I try my best to keep my urls clean and legible. One thing that has always troubled me is how to handle label creation of named things web users key into the app. For example if a user enters a name of a restaurant Alicanté Café the uri safe for of that (if there is no intervention) &#8216;Alicant%C3%A9%20Caf%C3%A9&#8217;, which is total gobblygoo and one might as well show a uid or something of that nature since at least that doesn&#8217;t physically hurt the eye. As someone who has worked on a lot of Restaurant related apps this has always been something I wanted there to be an easy solution to. This weekend I decided it was worth trying once again to see what would work best. And after reading the &#8220;Internationalization in Ruby&#8221;  in &lt;em&gt;The Ruby Way&lt;/em&gt;. Here is the super simple trick&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
require 'iconv'
strange_name = &quot;Alicanté Café&quot; 
converter = Iconv.new('ASCII//TRANSLIT', 'UTF-8')
converter.iconv(strange_name)
&quot;Alicant'e Caf'e&quot; 
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;It leaves some odd &#8217; and &#8220;sfor some reason but they will get stripped away with all the other potential weird stuff out (&#8221;,&#8217;,etc). Still this discovery makes me stop complaining about pretentious foreign sounding restaurant names.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-12:111</id>
    <published>2008-07-12T02:41:00Z</published>
    <updated>2008-07-12T02:58:20Z</updated>
    <category term=".bash_history"/>
    <category term="Hosting"/>
    <category term="note to self"/>
    <category term="Open Source"/>
    <category term="hosting"/>
    <category term="slicehost"/>
    <category term="ubuntu"/>
    <link href="http://baldur.snitchmedia.com/2008/7/12/big-problem-simple-solution" rel="alternate" type="text/html"/>
    <title>Big Problem ... simple solution</title>
<content type="html">
            &lt;p&gt;Here is an excellent case of a big problem &#8230; with a incredible simple solution. I upgraded my slicehost ubunto vpn from dapper to hardy. A risky business with nothing real in jeopardy except for the pride of  a 380 days up time on the server. I shut down everything running on the server and upgrade to hardy. All is fine except that I realize that when I am starting all the services that small things tab completion doesn&#8217;t work among other annoyances and doing work on a server without that is practically unbearable. So I figured I would make some time to fix it&#8230; the best place to go on these issues is slicehost &#8230; &lt;span class=&quot;caps&quot;&gt;THE ROCK&lt;/span&gt;. Tony on the slicehost campfire chat immediately identified the problem and it was fixed within 5 minutes.&lt;/p&gt;


	&lt;p&gt;*Tony  | try just running &#8220;bash&#8221;&lt;/p&gt;


	&lt;p&gt;And as he said that I was like shit and ran echo $SHELL only to realize that I was in &#8220;sh&#8221; but now everything is fixed and dandy and I have my tab completion back along with other normal bashy things &#8230; thank god. &lt;a href=&quot;http://www.slicehost.com/&quot;&gt;Did I mention that slicehost rocks!&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-11:110</id>
    <published>2008-07-11T02:53:00Z</published>
    <updated>2008-07-11T11:29:02Z</updated>
    <category term=".bash_history"/>
    <category term="note to self"/>
    <category term="Tips and Tricks"/>
    <category term="amazon storage"/>
    <category term="as3"/>
    <category term="ruby"/>
    <link href="http://baldur.snitchmedia.com/2008/7/11/how-to-make-an-object-in-a-amazon-s3-bucket-public" rel="alternate" type="text/html"/>
    <title>How to make an object in a amazon S3 bucket public!</title>
<content type="html">
            &lt;p&gt;Using &lt;a href=&quot;http://amazon.rubyforge.org/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;AWS&lt;/span&gt;::S3&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Now setting a object to :public_read is trivial if it&#8217;s done when you store it to S3. That doesn&#8217;t seem to be the case if you want to change on an object that already has been stored privately. After banging my head against it a bit I finally &#8220;got it&#8221; and I figured I would share it to either show off or try to be helpful.&lt;/p&gt;


	&lt;p&gt;dial into s3sh session see url above for details on how to store keys in environment variables etc.&lt;/p&gt;


	&lt;p&gt;once in there get a bucket object&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;my_bucket = Bucket.find(&#8216;foo&#8217;)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;now get the s3obj that you want to become public&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;s3obj = my_bucket[&#8216;object_name&#8217;]&lt;/li&gt;
		&lt;li&gt;policy = s3obj.acl&lt;/li&gt;
		&lt;li&gt;grant = &lt;span class=&quot;caps&quot;&gt;ACL&lt;/span&gt;::Grant.new&lt;/li&gt;
		&lt;li&gt;grant.permission = &#8216;READ&#8217;&lt;/li&gt;
		&lt;li&gt;grantee = &lt;span class=&quot;caps&quot;&gt;ACL&lt;/span&gt;::Grantee.new&lt;/li&gt;
		&lt;li&gt;grantee.group = &#8216;AllUsers&#8217;&lt;/li&gt;
		&lt;li&gt;grant.grantee = grantee&lt;/li&gt;
		&lt;li&gt;policy.grants &amp;lt;&amp;lt; grant&lt;/li&gt;
		&lt;li&gt;s3obj.acl(policy)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The access control on the buckets must be very rich since it&#8217;s this tricky make things public. I must be overlooking something.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-10:108</id>
    <published>2008-07-10T04:20:00Z</published>
    <updated>2008-07-10T04:28:10Z</updated>
    <category term=".bash_history"/>
    <category term="note to self"/>
    <category term="Ruby on Rails"/>
    <category term="Tips and Tricks"/>
    <category term="mephisto"/>
    <link href="http://baldur.snitchmedia.com/2008/7/10/bad-mephisto-move" rel="alternate" type="text/html"/>
    <title>Bad Mephisto Move</title>
<content type="html">
            &lt;p&gt;A while back I decided to get fancy and start hosting this blog on ec2 cloud just to sort of get the hang of working on that kind of a system. This of course involved moving database over and the works. Everything seemed to be going fine until I started posting&#8230; things were just busted bad. I kept getting&lt;/p&gt;


	&lt;p&gt;ActiveRecord::StatementInvalid (Mysql::Error: Duplicate entry &#8216;0&#8217; for key 1&lt;/p&gt;


	&lt;p&gt;errors and for the longest time I just ignored it since I was able to post by using a some of my masterpiece drafts that I wasn&#8217;t going to use any how&#8230; but then I ran out of those and I felt an urge to post but that meant I needed to tackle the problem and as it turned out it was a simple fix after I had done the research. The primary key fields had lost the &lt;span class=&quot;caps&quot;&gt;AUTO&lt;/span&gt;_INCREMENT magic during my db move and the solution was simply to go in and ad them where a appropriate.&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;ALTER TABLE&lt;/span&gt; `contents` &lt;span class=&quot;caps&quot;&gt;CHANGE&lt;/span&gt; `id` `id` &lt;acronym title=&quot;11&quot;&gt;INT&lt;/acronym&gt; &lt;span class=&quot;caps&quot;&gt;NOT NULL AUTO&lt;/span&gt;_INCREMENT;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-07-10:107</id>
    <published>2008-07-10T04:15:00Z</published>
    <updated>2008-07-10T04:20:14Z</updated>
    <category term="Nothing That Matters"/>
    <category term="Ruby on Rails"/>
    <category term="grubsnitch"/>
    <link href="http://baldur.snitchmedia.com/2008/7/10/playing-with-grubsnitch-again-7" rel="alternate" type="text/html"/>
    <title>playing with grubsnitch again</title>
<content type="html">
            &lt;p&gt;Boy is that place a rats nest&#8230; haven&#8217;t looked at the site for a year now and decided to see how long it would take me to upgrade to rails 2. Remarkable enough it was really not that tricky to do which speaks to the level of my knowledge of rails at the time which was fairly slim so all my upgrading tasks where fairly light. So to make things more exciting I decided make it more rest-y &#8230; which also was remarkable light task except for a few minor issues such as lack of tests which makes it terribly difficult to even know if the site is working at all except for the fact that I clicked around a bit &#8230; (god I wish I had known testing better a year ago). So before I would dive into upping the test coverage I decided to save the very little traffic I get from google by issuing a 301 for the urls that changed. So as an former mod_rewrite ninja (oh did I mention that I deployed the site before I fell in love with nginx) I fired up .htaccess and wrote all the rules for the rewrites &#8230; then after 30 minutes of cursing and moaning I read somewhere that .htaccess doesn&#8217;t take on rails app jez. Not to worry I just stuffed the rules into my virtualhost config and things are flying.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-06-05:59</id>
    <published>2008-06-05T11:18:00Z</published>
    <updated>2008-06-05T11:25:03Z</updated>
    <link href="http://baldur.snitchmedia.com/2008/6/5/respond_to_block" rel="alternate" type="text/html"/>
    <title>respond_to block</title>
<content type="html">
            &lt;p&gt;Don&#8217;t you just hate those gotchas out there that will consume some of too much of your time?&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
respond_to do |wants|
  format.js
  format.html
  format.xml
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;This snippet will run fine on everything except IE browsers which will try to download the .js file. This is because IE doesn&#8217;t specify &#8216;text/html&#8217; mime type explicitly in the &lt;span class=&quot;caps&quot;&gt;HTTP ACCEPT&lt;/span&gt; header. So for it to work on IE .html needs to be defined first.&lt;/p&gt;


	&lt;p&gt;Firefox
&#8220;text/xml,application/xml,application/xhtml+xml,&lt;strong&gt;text/html&lt;/strong&gt;;q=0.9,text/plain;q=0.8,image/png,&lt;strong&gt;/*;q=0.5&#8221;&lt;/p&gt;


	&lt;p&gt;on IE
&#8220;image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, */&lt;/strong&gt;&#8220;&lt;/p&gt;


	&lt;p&gt;To fix it the order just needs to be changed.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
respond_to do |wants|
  format.html
  format.js
  format.xml
end
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-03-07:71</id>
    <published>2008-03-07T02:05:00Z</published>
    <updated>2008-03-07T02:25:25Z</updated>
    <category term=".bash_history"/>
    <category term="note to self"/>
    <category term="Tips and Tricks"/>
    <category term="pdf"/>
    <category term="vim"/>
    <link href="http://baldur.snitchmedia.com/2008/3/7/pdf-from-vim-and-other-pdf-utilities" rel="alternate" type="text/html"/>
    <title>Pdf from VIM and other pdf utilities</title>
<content type="html">
            &lt;p&gt;It&#8217;s a continues struggle to become efficient in using &lt;span class=&quot;caps&quot;&gt;VIM&lt;/span&gt;, especially if one ventures outside of what one regularly needs to do. It&#8217;s well worth it though since it might be the last text editor that you&#8217;ll ever need to master.&lt;/p&gt;


	&lt;p&gt;I was faced with having to produce pdf with selected code snippets.&lt;/p&gt;


	&lt;p&gt;Here is the fastest approach&#8230; be warned this example is for macs but I am sure it can work in other Li/Unix environments as well.&lt;/p&gt;


	&lt;p&gt;Install &lt;a href=&quot;http://www.codepoetry.net/projects/cups-pdf-for-mosx&quot;&gt;&lt;span class=&quot;caps&quot;&gt;CUPS PDF&lt;/span&gt;&lt;/a&gt; and setup a virtual printer as is described on that page. Make sure that it&#8217;s the default printer after you have set it up.&lt;/p&gt;


	&lt;p&gt;The command to print in vim is :ha which is a short for :hardcopy this will spool the whole file to the print que for that driver and ultimately drop a pdf in cups-pdf folder on your desktop. To print out a selection simply highlight some text before issuing :ha command. I needed the line-numers of the code samples and this can be achieved by setting printoptions.&lt;/p&gt;


	&lt;p&gt;set printoptions=number:y&lt;/p&gt;


	&lt;p&gt;Now to be a complete terminal snob you should check out &lt;a href=&quot;http://www.pdfhacks.com/pdftk/&quot;&gt;pdftk&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-02-21:70</id>
    <published>2008-02-21T14:53:00Z</published>
    <updated>2008-02-21T15:17:24Z</updated>
    <category term="Javascript"/>
    <category term="Open Source"/>
    <category term="Tips and Tricks"/>
    <category term="event handling"/>
    <category term="javascript"/>
    <category term="Javascript"/>
    <category term="prototype"/>
    <link href="http://baldur.snitchmedia.com/2008/2/21/javascript-event-handling-evolved" rel="alternate" type="text/html"/>
    <title>Javascript Event Handling evolved</title>
<content type="html">
            &lt;p&gt;Just this week, &lt;a href=&quot;http://motionbox.com&quot;&gt;motionbox&lt;/a&gt; the company I work for released it&#8217;s first open source code the &lt;a href=&quot;http://code.google.com/p/motionbox/wiki/EventHandlerDocumentation&quot;&gt;Motionbox EventHandler&lt;/a&gt; spearheaded by &lt;a href=&quot;http://blog.toppingdesign.com/&quot;&gt;Topping Bowers&lt;/a&gt; with contributions from the rest of us in the group. The javascript library implements event delegation techniques and is built on the prototype library. There are other such &lt;a href=&quot;http://yuiblog.com/blog/2007/09/13/bubbling-library-by-caridy/&quot;&gt;libraries for yui&lt;/a&gt; which this was in part inspired by.&lt;/p&gt;


	&lt;p&gt;One of the kewlest thing about the library is the ability to subscribe dom elements to events before they even show up in the dom. Don&#8217;t take my word for it it was written up in &lt;a href=&quot;http://ajaxian.com/archives/motionbox-eventhandler-event-subscription-and-delegation&quot;&gt;ajaxian&lt;/a&gt;. There you have it: Topper, me and my colleges are almost famous now. &lt;a href=&quot;http://code.google.com/p/motionbox/&quot;&gt;If you are using prototype go and get the source and try it out it&#8217;s totally brilliant&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I have written about event handling before: &lt;a href=&quot;/2007/7/8/the-evolution-of-body-onload-unobtrusive-javascript&quot;&gt;The evolution of body onload Unobtrusive Javascript&lt;/a&gt; which might give some context on the topic of event handling in javascript.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-01-10:69</id>
    <published>2008-01-10T07:57:00Z</published>
    <updated>2008-01-10T12:58:25Z</updated>
    <category term="Tips and Tricks"/>
    <category term="database"/>
    <category term="rails"/>
    <category term="sql"/>
    <link href="http://baldur.snitchmedia.com/2008/1/10/deleting-duplicates-from-database" rel="alternate" type="text/html"/>
    <title>Deleting duplicates from MySQL database</title>
<content type="html">
            &lt;p&gt;It&#8217;s not uncommon that databases are filled with duplicate data sets. And it&#8217;s even more common that you want to clear it out so you don&#8217;t have to bothered with duplicates. This is obviously the sort of thing you want to fix at the entrance, on the way in to the database and not collect duplicates, but this solution works well if that is too late.&lt;/p&gt;


	&lt;p&gt;To get things started let&#8217;s write up a file that we can play with. I am using MySQL and I don&#8217;t know the &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; standard well enough to say but I am sure this example can be modified to work on other database servers. I generally just keep a file open and then retrieve it on the mysql console. &lt;a href=&quot;http://blogsnitch.s3.amazonaws.com/dup_tutorial.sql&quot;&gt;Download the example file&lt;/a&gt;.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;sql&quot;&gt;
mysql&amp;gt;  \. dup_tutorial.sql
&lt;/code&gt;
&lt;/pre&gt;

Creating a simple table to play with. And stuffing it with some data.
&lt;pre&gt;
&lt;code class=&quot;sql&quot;&gt;
CREATE TABLE peoples (
  id int(11) NOT NULL auto_increment,
  f_name varchar(128) NOT NULL default '',
  l_name varchar(128) NOT NULL default '',
  age text NOT NULL,
  updated_on timestamp NOT NULL default
       CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO peoples (f_name, l_name, age) 
   VALUES ('baldur', 'gudbjornsson', 28);
INSERT INTO peoples (f_name, l_name, age) 
   VALUES ('baldur', 'gudbjornsson', 28);
INSERT INTO peoples (f_name, l_name, age) 
   VALUES ('baldur', 'gudbjornsson', 28);
INSERT INTO peoples (f_name, l_name, age) 
   VALUES ('baldur', 'gudbjornsson', 31);
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;In this sample we have 4 rows and but there are only 2 rows unique if updated_on and id fields are not taken into the account. Now the way to query this to only receive the unique set  group by can be used or &lt;span class=&quot;caps&quot;&gt;SELECT DISTINCT&lt;/span&gt;.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;sql&quot;&gt;
SELECT *
FROM peoples 
GROUP BY f_name, l_name, age
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;And here is the trick to collect the others to dispose of them. First we&#8217;ll join the peoples table with a unique rows from it self in a sub query to retrieve the ones that don&#8217;t match.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;sql&quot;&gt;
SELECT o_peoples.id 
FROM peoples o_peoples
LEFT OUTER JOIN 
  (SELECT id 
   FROM peoples 
   GROUP BY f_name, l_name, age) u_peoples 
ON o_peoples.id = u_peoples.id
WHERE u_peoples.id IS NULL;
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Then we&#8217;ll delete those extra rows from the database. Do this at your own risk and obviously back up your database five times and have a quick recovery plan it things go south.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;sql&quot;&gt;
DELETE o_peoples 
FROM peoples o_peoples
LEFT OUTER JOIN 
  (SELECT Id FROM peoples 
   GROUP BY f_name, l_name, age) u_peoples
ON o_peoples.id = u_peoples.id
WHERE u_peoples.id IS NULL;
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2007-11-29:68</id>
    <published>2007-11-29T03:37:00Z</published>
    <updated>2007-11-29T03:58:59Z</updated>
    <category term=".bash_history"/>
    <category term="Javascript"/>
    <category term="Tips and Tricks"/>
    <category term="javascript"/>
    <category term="jslint"/>
    <link href="http://baldur.snitchmedia.com/2007/11/29/jslint-from-the-terminal" rel="alternate" type="text/html"/>
    <title>jslint from the terminal</title>
<content type="html">
            &lt;p&gt;Once you get into the habit of using jslint it&#8217;s hard not to, it&#8217;s just so satisfying when it passes and all the lint has been cleared away. The first few times I used I went to &lt;a href=&quot;http://www.jslint.com/&quot;&gt;the web application&lt;/a&gt; and pasted the file in there and looked at the results, fixed what was wrong and pasted it back into the original file. This is especially inconvenient if you use vim or emacs since pasting from an external environment has always been a bit of a challenge. But fear not, &lt;a href=&quot;http://www.crockford.com/&quot;&gt;Douglas Crowford&lt;/a&gt;, best known for his work on the json spec, has an extended version that works with rhino the java javascript interpreter. The advantage of using jslint through rhino is that you can inspect your javascript files from the terminal. Installing it on a mac is trivial just follow &lt;a href=&quot;http://peter.michaux.ca/article/2982&quot;&gt;Peters Michaux Install instructions&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Here is the short version:&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$&amp;gt; curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R7.zip
$&amp;gt; unzip rhino1_6R7.zip
$&amp;gt; cp rhino1_6R7/js.jar /Library/java/Extensions/
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Download the jslint file&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$&amp;gt; curl -O http://www.jslint.com/rhino/jslint.js
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;And then you should be able to:&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$&amp;gt; java org.mozilla.javascript.tools.shell.Main jslint.js your_program.js
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2007-11-19:67</id>
    <published>2007-11-19T03:50:00Z</published>
    <updated>2007-11-19T04:00:04Z</updated>
    <category term="Office Games"/>
    <category term="games"/>
    <link href="http://baldur.snitchmedia.com/2007/11/19/object-of-the-day" rel="alternate" type="text/html"/>
    <title>Object of the Day</title>
<content type="html">
            &lt;p&gt;It has been a while since I have added a game to the Office Games section. This one is very simple and entertaining.&lt;/p&gt;


	&lt;p&gt;Object of the Day can be played with virtual object such as photographs and also with actual physical objects.&lt;/p&gt;


	&lt;p&gt;The game requires two or more players. One player brings an obscure object for others to guess the purpose of that object. The goal is to bring an object that is obscure enough that it will take the others a while to guess what it is and what it&#8217;s used for.&lt;/p&gt;


	&lt;p&gt;The rules are very simple! don&#8217;t bring an object that is too obscure or from a field that is very specialized, and people will have to understand what it is after it is explained. The object has to be intact and cannot have been tempered with. Here are two examples of great objects.&lt;/p&gt;


	&lt;p&gt;Now try to guess what these objects and what their purpose could be?&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://blogsnitch.s3.amazonaws.com/object_of_the_day_1.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://blogsnitch.s3.amazonaws.com/object_of_the_day.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2007-11-12:65</id>
    <published>2007-11-12T00:12:00Z</published>
    <updated>2007-11-13T02:12:05Z</updated>
    <category term=".bash_history"/>
    <category term="Ruby on Rails"/>
    <category term="database"/>
    <category term="migrations"/>
    <category term="mysql"/>
    <category term="rails"/>
    <link href="http://baldur.snitchmedia.com/2007/11/12/11-12-2007" rel="alternate" type="text/html"/>
    <title>11/12 2007</title>
<content type="html">
            &lt;p&gt;One cool thing I learned today was that you can set the columns when you generate the rails migration from the terminal. The prepopulates the tabel generation code with the table names and datatype. This isn&#8217;t such a big find since it&#8217;s well documented in script/generate model&#8212;help. But here is how it looks.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
 script/generate model members name:string age:integer
 script/generate model portfolio member_id:integer body:text
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Another thing I just came to realize is that defining explicit foreign_key constraint to the database is probably a good idea. I don&#8217;t know too much about database administration but if I understand it correctly it helps with dataintegrity and probably performance if the table grows big. Adding indexes is also a plus. A little specifity never hurt anyone. This example is for &lt;span class=&quot;caps&quot;&gt;MYSQL&lt;/span&gt; with the InnoDB engine which I believe is the default for rails now.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
. . .
def self.up
  create_table :members do |t|
    t.column :name, :string
    t.column :age, :integer
  end
end
. . .

def self.up
  create_table :portfolios do |t|
    t.column :member_id, :integer
    t.column :body, :text
  end
  execute 'ALTER TABLE portfolios ADD CONSTRAINT fk_portfolios_member \\
     FOREIGN KEY (member_id) REFERENCES members(id)'
end 
. . .

&lt;/code&gt;
&lt;pre&gt;
          </content>  </entry>
</feed>
