<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Lucky-Dip Blog</title>
    <link>http://blog.lucky-dip.net</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Random wallpaper from socwall.com</title>
      <description>&lt;p&gt;I quite like http://socwall.com. They have a rss feed for recent posts, but I wrote a small script to download a random selection instead.&lt;/p&gt;
&lt;p&gt;
On OSX I could then set my desktop background to be a random picture from a folder. In my case that folder was /Users/brad/Pictures/Wallpapers/ but that could be easily changed.
&lt;/p&gt;
&lt;p&gt;
The code is after the jump.
&lt;/p&gt;

&lt;pre class="code"&gt;
#!/usr/bin/ruby

require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'Pathname'
 
URL = 'http://socwall.com/browse/index.php?wpSortby=8'
DEST = "/Users/brad/Pictures/Wallpapers/"


def clear_old_images
  Pathname.new(DEST).children.each { |f| f.delete }
end

def download_images(count)
  count = count.to_i
  
  while count &gt; 0
    doc = Hpricot(open(URL))
    
    doc.search("div.wpThumbnail").each do |thumb|
      next if count == 0
      
      thumbnail = thumb.at("img")['src']
      image = thumbnail.gsub(/\/tb_/, '/')
      image = image.gsub(" ", "%20")
      
      remote_image = open(image, "User-Agent" =&gt; "Ruby/#{RUBY_VERSION}")
      local_image = open("#{ DEST }/#{ count }.png", 'w')
      local_image.write(remote_image.read)
      
      remote_image.close
      local_image.close
      
      count -= 1
    end
  end
end

count = ARGV[0] || 10

clear_old_images
download_images(count)

&lt;/pre&gt;</description>
      <pubDate>Mon, 01 Sep 2008 18:10:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:26147d2a-d19b-4164-a22e-ab03958f265c</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2008/09/01/random-wallpaper-from-socwall-com</link>
      <category>ruby</category>
      <category>wallpaper</category>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/13</trackback:ping>
    </item>
    <item>
      <title>ZSH</title>
      <description>&lt;p&gt;I've been zsh lately. I get the feeling most shells have similar features, but somehow I stumbled across a good config file for this one. It's so good I think it is worth sharing.&lt;/p&gt;

&lt;p&gt;
Features that I like in zsh:
&lt;ul&gt;
&lt;li&gt;Standard aliases, reverse search, history work as normal&lt;/i&gt;
&lt;li&gt;Typos in command names and directories are fixed automatically&lt;/li&gt;
&lt;li&gt;Auto 'cd' if you just type the directory name.&lt;/li&gt;
&lt;li&gt;Completion of command options (so the - and -- options!)&lt;/li&gt;
&lt;li&gt;Copletion of rake task names. This might the same as above, but it's still handy.&lt;/li&gt;
&lt;li&gt;Completion of remote paths over scp. It's a bit slow for regular use, but can be good if you've forgotten the name of one dir.&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;
My zshrc is available here on github:
&lt;a href="http://github.com/bradx3/dotfiles/tree/master/.zshrc"&gt;http://github.com/bradx3/dotfiles/tree/master/.zshrc&lt;/a&gt;
&lt;/p&gt;

</description>
      <pubDate>Fri, 27 Jun 2008 14:01:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:de8990a6-ced4-4e1f-8bcd-49ff09ad8790</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2008/06/27/zsh</link>
      <category>zsh</category>
      <enclosure url="http://blog.lucky-dip.net/files/zshrc2" type="application/octet-stream" length="7343"/>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/12</trackback:ping>
    </item>
    <item>
      <title>performSelector in RubyCocoa</title>
      <description>&lt;p&gt;
I had a lot of trouble finding documentation for this. If you want to make a call on the main thread in RubyCocoa, the format is something like:
&lt;/p&gt;
&lt;pre class="code"&gt;
performSelectorOnMainThread_withObject_waitUntilDone('method_name:', object, true)
&lt;/pre&gt;

&lt;p&gt;
So two things that took me a while:
&lt;ol&gt;
&lt;li&gt;method_name has a trailing colon. &lt;/li&gt;
&lt;li&gt;The object the has the method you want to call should be the second argument. I got it in my head it should be the first for some reason.&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;

</description>
      <pubDate>Tue, 22 Apr 2008 15:01:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:dace920f-6826-4c1f-9893-6f7e58bcb965</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2008/04/22/performselector-in-rubycocoa</link>
      <category>ruby</category>
      <category>cocoa</category>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/11</trackback:ping>
    </item>
    <item>
      <title>Read table row-by-row in ruby</title>
      <description>&lt;p&gt;
I needed to export some data from a huge data table. Iterating through MyModel.find took too long and too much ram, so I went straight to the db instead. 
&lt;/p&gt;

Example code was tough to find, so here's an example:

&lt;pre class="code"&gt;
sql = "select * from #{ MyModel.table_name }"
MyModel.connection.execute(sql) do |handle|
  handle.fetch do |row|
    # row is an array of values
    ... export row ...
  end
end
&lt;/pre&gt;

</description>
      <pubDate>Wed, 12 Mar 2008 12:00:00 +1100</pubDate>
      <guid isPermaLink="false">urn:uuid:7f1cc0c7-4146-4e78-ab19-e968710cb720</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2008/03/12/read-table-row-by-row-in-ruby</link>
      <category>ruby</category>
      <category>rails</category>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/10</trackback:ping>
    </item>
    <item>
      <title>Named SQL Server Instances with FreeTDS</title>
      <description>&lt;p&gt;
&lt;a href="http://permalink.gmane.org/gmane.comp.db.tds.freetds/9182"&gt;A helpful post on accessing named sql server instances using freetds&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
I was having a lot of trouble doing that. Turns out the 'instance' key exists. As far as I could find it wasn't in the doc anywhere, so this is just a post in the hope that it'll save somebody else some time in the future.
&lt;/p&gt;

From the post:
&lt;pre class="code"&gt;
[def]
host = abc
instance = def
port = 1433
client charset = UTF-8
tds version = 8.0
&lt;/pre&gt;





</description>
      <pubDate>Mon, 10 Mar 2008 19:31:00 +1100</pubDate>
      <guid isPermaLink="false">urn:uuid:0b47ce36-fb23-4ab6-8d1e-249426f695dd</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2008/03/10/named-sql-server-instances-with-freetds</link>
      <category>freetds</category>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/9</trackback:ping>
    </item>
    <item>
      <title>Using Javascript Code for RJS Instead of IDs</title>
      <description>Some info on how to make RJS output code like:
&lt;pre&gt;&lt;code class="ruby"&gt;
new Insertion.Bottom($$('p.welcome b').first(), "Some item"
&lt;/code&gt;&lt;/pre&gt;
&lt;a href="http://sentia.com.au/2008/03/using-javascript-code-for-rjs.html"&gt;http://sentia.com.au/2008/03/using-javascript-code-for-rjs.html&lt;/a&gt;

</description>
      <pubDate>Mon, 05 Nov 2007 12:31:00 +1100</pubDate>
      <guid isPermaLink="false">urn:uuid:6b38ca78-8f3b-4eb0-b3a5-9c95cce806e9</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2007/11/05/using-javascript-code-for-rjs-instead-of-ids</link>
      <category>rails</category>
      <category>rjs</category>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/8</trackback:ping>
    </item>
    <item>
      <title>Redish Greenish for ZenTest</title>
      <description>&lt;p&gt;
&lt;a href="http://www.zenspider.com/ZSS/Products/ZenTest/"&gt;ZenTest&lt;/a&gt; is a great tool. I use it and its redgreen plugin a lot to easily keep an eye on my tests.
&lt;/p&gt;

&lt;p&gt;
I use a green terminal background though, so when my tests pass, rather than a green line, I have to rely on a lack of a red line. This isn't so bad, but I thought it could be improved with a little effort.
&lt;/p&gt;

&lt;p&gt;
Redish greenish is an extension of redgreen that allows you to specify the colours used for tests passing and/or failing.
&lt;/p&gt;

&lt;p&gt;
To use it, &lt;a href="http://blog.lucky-dip.net/files/redishgreenish.rb"&gt;save this file&lt;/a&gt; into your autotest lib directory. (Mine is GEM_PATH/1.8/gems/ZenTest-3.6.1/lib/autotest/). To enable redishgreenish, you'll need to modify your autotest config file. Open "~/.autotest" and change the line:
&lt;br /&gt;
&lt;code&gt;
require 'autotest/redgreen'
&lt;/code&gt;
&lt;br /&gt;
to 
&lt;br /&gt;
&lt;code&gt;
require 'autotest/redishgreenish'
&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
At this point, autotest will behave exactly the same as if redgreen was used. To change the colour of the lines used to signify tests passing and failing, your autotest config file should look like
&lt;br /&gt;
&lt;code&gt;
PASSED = :blue
&lt;br /&gt;
FAILED = :yellow
&lt;br /&gt;
require 'autotest/redishgreenish'
&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
Valid values for colours are
&lt;br /&gt;
&lt;code&gt;
:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white
&lt;/code&gt;
&lt;/p&gt;

</description>
      <pubDate>Sat, 29 Sep 2007 13:26:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:3a006676-a8cc-48ec-898e-f37123a6071b</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2007/09/29/redish-greenish-for-zentest</link>
      <category>zentest</category>
      <trackback:ping>http://blog.lucky-dip.net/articles/trackback/7</trackback:ping>
    </item>
    <item>
      <title>Haml &amp;amp; Sass Editors 0.5.4</title>
      <description>&lt;p&gt;Last release didn't go so well. For some reason I figured other people had tried to install Aptana, had it fail and then given up on it like me. Turns out I was alone haha.&lt;/p&gt;

&lt;p&gt;
So I spent a bit of time figuring out what changed in RDT and fixed things up. I've tested this with a straight out of the box install of Aptana m8, so hopefully it'll work for others too.&lt;/p&gt;

&lt;p&gt;
If anybody does try it, please let me know if it works or not. I'm going to use this blog post as a bit of a test before I post to the Haml mail list. Thanks in advance to anyone who replies!&lt;/p&gt;

&lt;p&gt;
(Oh yeah, the update site is still http://haml.lucky-dip.net/).
&lt;/p&gt;

</description>
      <pubDate>Fri, 06 Jul 2007 13:49:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:00d5ee5e-3e09-4444-b336-2fc237360171</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2007/07/06/haml-sass-editors-0-5-4</link>
      <category>haml</category>
      <category>sass</category>
      <category>aptana</category>
    </item>
    <item>
      <title>Haml &amp;amp; Sass Editor For Eclipse</title>
      <description>&lt;p&gt;
I did some very basic editors for Haml and Sass a while back. At the time I was interested in Haml. It's elegant to write, and the automatically formatted html it outputs just made it a match made in heaven.
&lt;/p&gt;
&lt;p&gt;
Fast forward a few months and now I'm actually using Haml and Sass. It's as good as I ever hoped it would be. With Haml and a little bit of FormBuilder magic I'm making useful forms in four short lines. Too good.
&lt;/p&gt;
&lt;p&gt;
Anyway coming with using it is the chance to see some shortcomings in my own editors, so I've spent a bit of time updating them. I've set up a proper Eclipse update site, so you can just add 'http://haml.lucky-dip.net' via the 'Help - Software Updates - Find and Install' menu option. That should help minimize a few errors with the various versions of Eclipse and RDT around. All references to the RadRails plugins have been removed. There was a bit of code that I pulled into my plugin, but with RadRails/Aptana in heavy dev it's easier for me to forget about trying to keep up for a while.
&lt;/p&gt;
&lt;p&gt;
Also added is code folding. There's a bit of work still to do on this one. You can currently only fold top level elements. This can be a pain when you've got all your code in one file, but if you're using layouts and partial in a sensible way it should hopefully be of some use. 
&lt;/p&gt;
&lt;p&gt;
One thing I found a bit tricky was figuring out which element I was under when I was editing. Some people might like turning on space markers (can you actually do that in Eclipse?), but I figured a character matcher would do the trick. So now as you move around in the editors there'll be a blue box around the element you are currently in. At the moment it just highlights the first letter of the element. I'm going to see if I can get the whole element happening for the next release.
&lt;/p&gt;
&lt;p&gt;
So I hope it works well for people. Set up an Eclipse update site of 'http://haml.lucky-dip.net' and that should keep you informed as new versions come out.
&lt;/p&gt;

</description>
      <pubDate>Sun, 24 Jun 2007 14:58:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:e00587d0-2429-495a-8a8a-29846c3372ab</guid>
      <author>Brad</author>
      <link>http://blog.lucky-dip.net/articles/2007/06/24/haml-sass-editor-for-radrails</link>
      <category>haml</category>
      <category>sass</category>
      <category>eclipse</category>
      <category>radrails</category>
    </item>
  </channel>
</rss>
