<?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>Configuring QuickProxy FireFox plugin</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/155/" />
				<id>http://www.deheus.net/petrik/blog/post/155/</id>
		<modified>2008-07-16T19:10:58Z</modified>
		<issued>2008-07-16T19:10:58Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>While trying out Ratproxy I needed to use QuickProxy.<br />
I couldn't find any configuration description, so here is what I did.<br />
Go to: Preferences > Advanced > Network, and set HTTP Proxy to localhost a
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>While trying out Ratproxy I needed to use QuickProxy.<br />
I couldn't find any configuration description, so here is what I did.<br />
Go to: Preferences > Advanced > Network, and set HTTP Proxy to localhost and Port to 8080 for the default Ratproxy settings.<br />
To turn QuickProxy on/off click the 'P' icon in the status bar.
</p>
]]></content>
	</entry>
		<entry>
	  	<author>
			<name>Petrik de Heus</name>
		</author>
		<title>Seam, a second look at JSF</title>
		<link rel="alternate" type="text/html" href="http://www.deheus.net/petrik/blog/post/154/" />
				<id>http://www.deheus.net/petrik/blog/post/154/</id>
		<modified>2008-07-10T22:04:55Z</modified>
		<issued>2008-07-10T22:04:55Z</issued>
		<summary type="text/html" mode="escaped"><![CDATA[	<p>I decided to have another look at JSF by reading the Tutorial. The last time I used JSF was 2 years ago (I thought it sucked then). Maybe it has improved with Seam. </p>
	<p>Besides almost falling asleep f
</p>
]]></summary>
		<content type="text/html" mode="escaped"><![CDATA[	<p>I decided to have another look at JSF by reading the Tutorial. The last time I used JSF was 2 years ago (I thought it sucked then). Maybe it has improved with Seam. </p>
	<p>Besides almost falling asleep from all the xml I did notice Seam supports Ruby style templating Strings(example 1.2), which is sort of nice.<br />
I'm not sure if you can use simple java oneliners though.</p>
	<p>A couple of things that suck:</p>
	<p>- Validation of required fields in views (Example 1.7)</p>
	<p>  Username: </p>
	<p>- Session beans require an interface. Let's define everything twice!</p>
	<p>- Displaying a simple date requires 120 chars (Example 1.12)</p>
	<p>- Configuration in the views and confusing prefixes.</p>
	<p>- Removing duplication from views sucks because you can't extract methods.</p>
	<p>I actually forgot how much JSF sucked (I remember it was hard to test).<br />
The biggest problem  is that it's been developed by someone who doesn't use it to write real applications.<br />
It's full of crappy implementations of concepts that seem like a good idea from an ivory tower.</p>
	<p>Here is a script that generates the same application in Rails(2.1), it's just a bit longer than just the web.xml from the seam example:</p>
	<p>puts `rails seam`<br />
Dir.chdir "seam"<br />
open('config/database.yml', 'w') do |f|<br />
f </p>
	<p>puts `script/generate model user username:string password:string name:string`<br />
open('app/models/user.rb', 'w') do |f|<br />
f  5..15<br />
  validates_presence_of :name<br />
  validates_length_of :username, :in => 5..15<br />
  validates_uniqueness_of :username<br />
end}<br />
end</p>
	<p>puts `script/generate controller Register`<br />
open('app/controllers/register_controller.rb', 'w') do |f|<br />
f  :registered if params[:user] && @user.save<br />
  end<br />
end}<br />
end</p>
	<p>open('app/views/register/index.html.erb', 'w') do |f|<br />
f  :index} do |f| %><br />
   Username:<br />
   Real Name:<br />
   Password: </p>
	<p>}<br />
end</p>
	<p>open('app/views/register/registered.html.erb', 'w') do |f|<br />
f </p>
	<p>puts `rake db:migrate`
</p>
]]></content>
	</entry>
		<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>
	</feed>