<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/petrik/css/style.xsl" media="screen"?><feed version="0.3"
  xmlns="http://purl.org/atom/ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="en">
	<title>Petrik de Heus</title>
	<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/" />
	<tagline>Sporadically updated weblog of Petrik de Heus</tagline>
	<modified>1970-01-01T00:00:00Z</modified>
	<copyright>Copyright 1970</copyright>
	<generator url="http://www.four54.com/">SmallBlock</generator>

    	<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Cartoons van journalist verboden, Volkskrant zwijgt</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/152/" />
				<id>http://www.deheus.net/petrik/blog/post/152/</id>
		<modified>2008-03-22T08:09:52Z</modified>
		<issued>2008-03-22T08:09:52Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>http://www.volkskrantblog.nl/bericht/191036
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>http://www.volkskrantblog.nl/bericht/191036
</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Ordina puzzle in Ruby</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/151/" />
				<id>http://www.deheus.net/petrik/blog/post/151/</id>
		<modified>2007-12-08T19:14:57Z</modified>
		<issued>2007-12-08T19:14:57Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>Ordina is running a campaign to attract Java developers.</p>
	<p>Here is my version of the puzzle in Ruby. For a better comparison I've kept some of the Java style code and refrained from some one liners.
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>Ordina is running a campaign to attract Java developers.</p>
	<p>Here is my version of the puzzle in Ruby. For a better comparison I've kept some of the Java style code and refrained from some one liners. Still, it's about half as long as the Java version.<br />
My solution to the puzzle uses wikipedia to lookup the acronyms.</p>
	<p>ordina.rb</p>
	<p>require 'open-uri'<br />
module Nl<br />
  module Ordina<br />
    class JavaSpecialist</p>
	<p>      def self.main<br />
        js = find_specialist_wanna_be<br />
        if js<br />
          js.start<br />
        else<br />
          puts "Geen JavaSpecialist implementatie gevonden"<br />
        end<br />
      end</p>
	<p>      def start<br />
        report = "Volgens de specialist #{name}\x5c\x6eHebben de volgende termen de betekenis" +<br />
                  "\x5c\x6e\x55\x4d\x4c #{eval "waarStaat\x55\x4d\x4cVoor" } \x5c\x6e\x52\x55\x50 " +<br />
                  "#{eval "waarStaat\x52\x55\x50Voor" } \x5c\x6e\x58\x4d\x4c #{eval "waarStaat\x58\x4d\x4cVoor" } " +<br />
                  "\x5c\x6e\x4d\x56\x43 #{eval "waarStaat\x4d\x56\x43Voor" } \x5c\x6e\x45\x4a\x42 " +<br />
                  "#{eval "waarStaat\x45\x4a\x42Voor" }\x5c\x6e\x41\x4f\x50 #{eval "waarStaat\x41\x4f\x50Voor" } " +<br />
                  "\x5c\x6e\x4a\x53\x46 #{eval "waarStaat\x4a\x53\x46Voor" }"<br />
        puts report.gsub!('\n', "\n")<br />
        puts kijk_bij_ordina<br />
      end      </p>
	<p>      private</p>
	<p>      def self.find_specialist_wanna_be<br />
        dir = Nl::Ordina.name.gsub('::', '/').downcase<br />
        Dir.new(dir).each{|i| require("#{dir}/#{i}") unless File.directory?("#{dir}/#{i}") }<br />
        Nl::Ordina.constants.each do |i|<br />
          unless i == self.name.split('::').last<br />
            obj = instance_eval(i).new<br />
            return obj if obj.is_a? JavaSpecialist<br />
          end<br />
        end<br />
      end</p>
	<p>      def kijk_bij_ordina<br />
        open("http://jobportal.ordina.nl/jobportal-front/pages/index.jsf").read<br />
      rescue<br />
        'Kijk op http://jobportal.ordina.nl/'<br />
      end<br />
    end<br />
  end<br />
end<br />
Nl::Ordina::JavaSpecialist.main</p>
	<p>nl/ordina/impl.rb</p>
	<p>module Nl<br />
  module Ordina<br />
    class JavaSpecialistImpl < JavaSpecialist<br />
      def name<br />
        "p8"<br />
      end</p>
	<p>      def method_missing(*args)<br />
        afk = args.first.to_s.gsub('waarStaat', '').gsub('Voor', '')<br />
        page = open("http://en.wikipedia.org/wiki/#{afk}").read<br />
        matchdata = /([^>]*)()/.match(page)<br />
        matchdata ? matchdata[1].gsub('- Wikipedia, the free encyclopedia', '') : 'Onbekend'<br />
      end<br />
    end<br />
  end<br />
end</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/149/" />
				<id>http://www.deheus.net/petrik/blog/post/149/</id>
		<modified>2007-07-21T10:20:36Z</modified>
		<issued>2007-07-21T10:20:36Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>OSX crashed yesterday and after restarting I got the following error in some php apps</p>
	<p>Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'.</p>
	<p>This happened once before so I
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>OSX crashed yesterday and after restarting I got the following error in some php apps</p>
	<p>Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'.</p>
	<p>This happened once before so I'm documenting the proper solution here for possible later use.</p>
	<p>sudo /usr/sbin/apachectl stop<br />
apache2ctl start</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Setting the default Browser on OSX with Ruby</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/147/" />
				<id>http://www.deheus.net/petrik/blog/post/147/</id>
		<modified>2007-07-06T22:39:54Z</modified>
		<issued>2007-07-06T22:39:54Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>To combat my ADD I want to seperate my work and private browsing. So having two seperate workspaces sounds like a good idea.</p>
	<p>I tried Virtue Desktop (and all the other ones) but they were useless to
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>To combat my ADD I want to seperate my work and private browsing. So having two seperate workspaces sounds like a good idea.</p>
	<p>I tried Virtue Desktop (and all the other ones) but they were useless to me, because all the virtual desktops show all running applications when switching application with Command+tab. I only want to see the ones in my current desktop.</p>
	<p>Creating another user account isn't an option either because I want to access my mail for both work and private use.</p>
	<p>So I need a browser switcher I can run from the commandline so I can schedule it with crontab.</p>
	<p>The Objective C part<br />
For the Objecive C part I create a SwitchBrowser directory.<br />
In it I create a file called ~/SwitchBrowser/SwitchBrowser.h:</p>
	<p>#import </p>
	<p>@interface SwitchBrowser : NSObject<br />
{}<br />
- (CFArrayRef) browsers;<br />
- (void)setDefaultBrowser: (CFStringRef) newDefaultStr;<br />
@end</p>
	<p>... and a file called ~/SwitchBrowser/SwitchBrowser.m:<br />
(Copied from Giant Mike's FavBrowse)</p>
	<p>#import "SwitchBrowser.h"</p>
	<p>@implementation SwitchBrowser</p>
	<p>- (CFArrayRef) browsers {<br />
    return LSCopyAllHandlersForURLScheme(CFSTR("https"));<br />
}</p>
	<p>- (void)setDefaultBrowser: (CFStringRef) newDefaultStr<br />
{</p>
	<p>	//Set the launch services settings for https:// and http://<br />
	LSSetDefaultHandlerForURLScheme(CFSTR("https"), newDefaultStr);<br />
	LSSetDefaultHandlerForURLScheme(CFSTR("http"), newDefaultStr);</p>
	<p>	//Set the launch services setting for web sites discovered via Bonjour<br />
	LSSetDefaultRoleHandlerForContentType(CFSTR("public.html"), kLSRolesAll, newDefaultStr);</p>
	<p>	FSRef newDefaultBrowserFSRef;<br />
	LSFindApplicationForInfo(kLSUnknownCreator, newDefaultStr, NULL, &newDefaultBrowserFSRef, NULL);<br />
	_LSSetWeakBindingForType(kLSUnknownType, kLSUnknownCreator, CFSTR("xhtm"), kLSRolesAll, &newDefaultBrowserFSRef);<br />
}</p>
	<p>@end</p>
	<p>void Init_switch_browser(){}</p>
	<p>In the SwitchBrowser directory everything is compiled with the following command:</p>
	<p>gcc -o switch_browser.bundle -bundle -framework Foundation -framework ApplicationServices -framework AppKit SwitchBrowser.m</p>
	<p>The RubyCocoa Part</p>
	<p>I use RubyCocoa for the scripting part.<br />
After installing it, create a file called ~/switch_browser.rb:</p>
	<p>#!/usr/bin/env ruby</p>
	<p>require 'osx/cocoa'<br />
require File.dirname(__FILE__) + '/SwitchBrowser/switch_browser'</p>
	<p>new_browser = $*[0]</p>
	<p>OSX.ns_import :SwitchBrowser<br />
switcher = OSX::SwitchBrowser.alloc.init<br />
browsers = switcher.browsers.collect{|b| b }</p>
	<p>unless new_browser<br />
  puts "Select browser number:"<br />
  browsers.each_with_index{|b,i| puts "#{i} #{b}"}<br />
  new_browser = browsers[gets.chomp!.to_i]<br />
end</p>
	<p>raise "#{new_browser} is not a valid browser." unless browsers.include? new_browser</p>
	<p>switcher.setDefaultBrowser(new_browser)<br />
puts "Switched to " + new_browser</p>
	<p>Now you can do:<br />
~/switch_browser.rb org.mozilla.firefox</p>
	<p>I've added this to my crontab together with quiting my work applications on the end of my workday.<br />
It's been a real improvement!
</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Learning Erlang: Control Structures</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/137/" />
				<id>http://www.deheus.net/petrik/blog/post/137/</id>
		<modified>2007-07-06T22:08:43Z</modified>
		<issued>2007-07-06T22:08:43Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>So far, we haven’t seen any if statements, or switch statements or for statements, or while statements, and yet this doesn’t seem to matter. Everything is written using pattern-matching and higher
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>So far, we haven’t seen any if statements, or switch statements or for statements, or while statements, and yet this doesn’t seem to matter. Everything is written using pattern-matching and higher order functions. So far we haven’t needed any additional control structures.<br />
If we want additional control structures we have a power ful glue that we can use to make our own control structures....</p>
	<p>As you become more experienced, you’ll find that being able to create your own control structures can dramatically decrease the size of your programs and sometimes make them a lot clearer. This is because you can create exactly the right control structures that are needed to solve your problem, and you are not restricted by a small and fixed set of control structures that came with your programming language.</p>
	<p>Programming Erlang
</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Paul Graham on seperating coding and planning</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/146/" />
				<id>http://www.deheus.net/petrik/blog/post/146/</id>
		<modified>2007-06-24T07:56:44Z</modified>
		<issued>2007-06-24T07:56:44Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>Paul Graham in On Lisp:<br />
Experienced programmers know that no matter how carefully you plan a program, when you write it the plans will turn out to be imperfect in some way. Sometimes the plans will b
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>Paul Graham in On Lisp:<br />
Experienced programmers know that no matter how carefully you plan a program, when you write it the plans will turn out to be imperfect in some way. Sometimes the plans will be hopelessly wrong. Yet few of the victims of the plan-and-implement method question its basic soundness. Instead they blame human failings: if only the plans had been made with more foresight, all this trouble could have been avoided. Since even the very best programmers run into problems when they turn to implementation, perhaps it’s too much to hope that people will ever have that much foresight.</p>
	<p>...</p>
	<p>As Montaigne found, nothing clarifies your ideas like trying to write them down. Once you’re freed from the worry that you’ll paint yourself into a corner, you can take full advantage of this possibility. The ability to plan programs as you write them has two momentous consequences: programs take less time to write, because when you plan and write at the same time, you have a real program to focus your attention; and they turn out better, because the final design is always a product of evolution. So long as you maintain a certain discipline while searching for your program’s destiny—so long as you always rewrite mistaken parts as soon as it becomes clear that they’re mistaken—the final product will be a program more elegant than if you had spent weeks planning it beforehand.</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Paul Graham on the power of Lisp</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/145/" />
				<id>http://www.deheus.net/petrik/blog/post/145/</id>
		<modified>2007-06-17T21:13:52Z</modified>
		<issued>2007-06-17T21:13:52Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>Paul Graham:<br />
If you understand how compilers work, what's really going on is not so much that Lisp has a strange syntax as that Lisp has no syntax. You write programs in the parse trees that get gene
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>Paul Graham:<br />
If you understand how compilers work, what's really going on is not so much that Lisp has a strange syntax as that Lisp has no syntax. You write programs in the parse trees that get generated within the compiler when other languages are parsed. But these parse trees are fully accessible to your programs. You can write programs that manipulate them. In Lisp, these programs are called macros. They are programs that write programs.
</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Running Heckle on Rails classes</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/144/" />
				<id>http://www.deheus.net/petrik/blog/post/144/</id>
		<modified>2007-06-11T18:16:13Z</modified>
		<issued>2007-06-11T18:16:13Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>I couldn't find any documentation on running Heckle on Rails classes.</p>
	<p>The following worked for me:</p>
	<p> heckle Release -T 1 -t test/unit/release_test.rb<br />
 heckle ReleaseController -T 1 -t test/con
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>I couldn't find any documentation on running Heckle on Rails classes.</p>
	<p>The following worked for me:</p>
	<p> heckle Release -T 1 -t test/unit/release_test.rb<br />
 heckle ReleaseController -T 1 -t test/controllers/release_controller_test.rb</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Cron Scheduler for cruisecontrol.rb</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/143/" />
				<id>http://www.deheus.net/petrik/blog/post/143/</id>
		<modified>2007-06-09T09:52:52Z</modified>
		<issued>2007-06-09T09:52:52Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>Yesterday I built a Cron Scheduler plugin for cruisecontrol.rb. When installed the latest build always gets run on the scheduled time.<br />
It uses the same format as cron: minutes  hours    mday     mont
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>Yesterday I built a Cron Scheduler plugin for cruisecontrol.rb. When installed the latest build always gets run on the scheduled time.<br />
It uses the same format as cron: minutes  hours    mday     month    wday<br />
For now only minutes, hours and weekdays can be set.</p>
	<p>Examples of allowed patterns are:<br />
10    = run every 10th minute<br />
1,2,3 = run every 1st, 2nd and 3rd minute<br />
*     = run every minute<br />
*/2   = run every 2 minutes<br />
9-18  = run from 9 till 18<br />
1-9/3 = run from 1 till 9 with steps of 3</p>
	<p>To use it unpack it into CCRB's builder_plugins/installed directory.<br />
Then add it to your config:</p>
	<p>Project.configure do |project|<br />
  ...<br />
  project.scheduler = CronScheduler.new(project)<br />
  project.scheduler.cron = "*/15 9-18/3 * * 1,3,5"<br />
end</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Some things I learned at RubyEnRails 2007</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/139/" />
				<id>http://www.deheus.net/petrik/blog/post/139/</id>
		<modified>2007-06-08T08:44:15Z</modified>
		<issued>2007-06-08T08:44:15Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>rSpec can create nice documentation by looking at the example/test.</p>
	<p>With rSpec you can define empty tests that show up as todo's in reports.</p>
	<p>Netbeans has really nice Ruby support, including meth
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>rSpec can create nice documentation by looking at the example/test.</p>
	<p>With rSpec you can define empty tests that show up as todo's in reports.</p>
	<p>Netbeans has really nice Ruby support, including method completion for all classes.</p>
	<p>:to_yaml is handier for debugging than :inspect.</p>
	<p>Anything in a ruby script after __END__ is available in the DATA Constant.</p>
	<p>The membership administration for the dutch user group of another programming language runs on Rails.</p>
	<p>Fakeweb is a nice gem for faking web requests.</p>
	<p>:balanced_asset_url can speed up your page loads.</p>
	<p>Munin and  are nice projects for analyzing bottlenecks.
</p>
]]></content>
	</entry>
	</feed>