<?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>Jason Fox &#187; Programming</title>
	<atom:link href="http://www.jasonfox.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonfox.com</link>
	<description>programming, products, and pontifications...</description>
	<lastBuildDate>Thu, 17 Jun 2010 02:29:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Installing MySQL with the InnoDB Plugin</title>
		<link>http://www.jasonfox.com/2010/03/installing-mysql-with-the-innodb-plugin/</link>
		<comments>http://www.jasonfox.com/2010/03/installing-mysql-with-the-innodb-plugin/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 23:48:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=220</guid>
		<description><![CDATA[

I found after installing MySQL 5.1 that the “fast index creation”  feature is not utilized by the default InnoDB storage engine that comes  with MySQL 5.1.  This is the main reason why I went through the trouble  of installing  MySQL 5.1 in the first place.  :-/  However, have [...]]]></description>
			<content:encoded><![CDATA[<div id="OriginalPost">
<div>
<p>I found after installing MySQL 5.1 that the “fast index creation”  feature is not utilized by the default InnoDB storage engine that comes  with MySQL 5.1.  This is the main reason why I went through the trouble  of <a href="http://www.jasonfox.com/2010/03/installiing-and-running-mysql-5-1-next-to-5-0/">installing  MySQL 5.1 in the first place</a>.  :-/  However, have no fear, the <a href="http://www.innodb.com/products/innodb_plugin/features">InnoDB  plugin</a> is here!  (ok, that was lame, anyways…)</p>
<p>The InnoDB plugin is a replacement InnoDB storage engine developed  with the help of Sun, Google and Percona.  It supposedly provides better  overall performance compared with the default InnoDB storage engine  that comes with MySQL and it adds a few new features that I want such as  “fast index creation.”</p>
<p>If you’d like to try out the InnoDB plugin you’ll have to recompile  MySQL as a pre-compiled binary drop-in is not provided yet for OSX.  So, here are the steps for compiling and  installing MySQL 5.1 with the InnoDB plugin while maintaining a working  MySQL 5.0 installation on your computer.</p>
<ol>
<li>Download the <a href="http://dev.mysql.com/downloads/mysql/5.1.html#source">MySQL 5.1  source distribution</a> (v.5.1.43 for me; Change Platform to: Source  Code; Scroll down to the last distribution: Generic Linux (Architecture  Independent))</li>
<li>Download the <a href="http://www.innodb.com/products/innodb_plugin/download/">InnoDB  plugin source distribution</a> (v.1.0.6 for me)</li>
<li>Create a new install directory for MySQL 5.1: <code>sudo mkdir  /usr/local/mysql-5.1.43</code></li>
<li>Change ownership of the install directory to the mysql user: <code>sudo  chown -R mysql /usr/local/mysql-5.1.43</code></li>
<li>Extract the MySQL source: <code>tar -zxf mysql-5.1.43.tar.gz</code></li>
<li>Extract the InnoDB plugin source: <code>tar -zxf  innodb-1.0.6.tar.gz</code></li>
<li>Change into the MySQL source directory for storage engines: <code>cd  mysql-5.1.37/storage</code></li>
<li>Remove the version of the InnoDB plugin that MySQL comes with: <code>rm  -fr innobase</code></li>
<li>Replace the InnoDB plugin with the one you downloaded: <code>mv  innodb-1.0.6 innobase</code></li>
<li>Change into the MySQL source root: <code>cd ..</code></li>
<li>Create the make file: <code>./configure  --prefix=/usr/local/mysql-5.1.43 --with-extra-charsets=complex  --enable-thread-safe-client --enable-local-infile --enable-shared  --with-plugins=innobase --without-plugin-innodb_plugin  --with-federated-storage-engine</code>; note, I’m also including the <a href="http://dev.mysql.com/doc/refman/5.1/en/federated-storage-engine.html">Federated  Storage Engine</a> here in case you find a use for it in the future; <strong>NOTE</strong>: You will receive the following  warning, however, <a href="http://bugs.mysql.com/bug.php?id=42872">IT DID WORK</a>, so just ignore it:
<pre><code>configure: WARNING: unrecognized options: --without-plugin-innodb_plugin, --with-federated-storage-engine</code></pre>
</li>
<li>Compile MySQL: <code>make</code>; takes about 10 minutes or so</li>
<li>Install MySQL: <code>sudo make install</code></li>
<li>Change into your install directory: <code>cd  /usr/local/mysql-5.1.43</code></li>
<li>Create the MySQL database: <code>sudo ./bin/mysql_install_db  --user=mysql</code></li>
<li>Change ownership of the <code>var</code> directory to the mysql  user: <code>sudo chown -R mysql ./var</code></li>
</ol>
<h2>For more information see…</h2>
<p>If you get stuck you can check out the following resources that I  used to complete this process:</p>
<ul>
<li><a href="http://www.innodb.com/doc/innodb_plugin-1.0/innodb-plugin-installation.html#innodb-plugin-installation-source-unix">InnoDB  Plugin Installation Guide</a></li>
<li><a href="http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/">Installing  MySQL on OSX Snow Leopard</a> or the <a href="http://hivelogic.com/articles/installing-mysql-on-mac-os-x/">non-Snow  Leopard version</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/installing-source.html">MySQL  5.1 Installation Guide</a></li>
</ul>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2010/03/installing-mysql-with-the-innodb-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Apache2 with SSL Support on Mac OS X</title>
		<link>http://www.jasonfox.com/2010/03/installing-apache2-with-ssl-support-on-mac-os-x/</link>
		<comments>http://www.jasonfox.com/2010/03/installing-apache2-with-ssl-support-on-mac-os-x/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 23:58:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=227</guid>
		<description><![CDATA[Here are the steps for installing Apache2 with SSL  support on your local development machine.  Several of our applications  require HTTPS for certain actions and I’ve  been bitten in the past by not testing this in development.  So, here&#8217;s how to get Apache up and running with SSL.
Compiling and Installing [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the steps for installing Apache2 with SSL  support on your local development machine.  Several of our applications  require HTTPS for certain actions and I’ve  been bitten in the past by not testing this in development.  So, here&#8217;s how to get Apache up and running with SSL.</p>
<h2>Compiling and Installing Apache</h2>
<ol>
<li>Download the latest source distribution (v2.2.15 for me) from: <a href="http://httpd.apache.org/">http://httpd.apache.org</a></li>
<li>Extract the source: <code>tar -xvf httpd-2.2.15.tar.gz</code></li>
<li>Create an install directory (I put it in <code>/usr/local</code>):  <code>sudo makedir /usr/local/apache2</code></li>
<li>Configure the makefile with the following options: <code>./configure  --prefix=/usr/local/apache2 --enable-ssl --enable-setenvif  --enable-proxy --enable-headers</code></li>
<li>Compile the source code: <code>make</code></li>
<li>Install apache: <code>sudo make install</code></li>
<li>Create your self-signed SSL keys by  following this tutorial: <a href="http://developer.apple.com/internet/serverside/modssl.html">http://developer.apple.com/internet/serverside/modssl.html</a>
<ul>
<li>Scroll down to the Configuring SSL  section and start from there</li>
<li>You will need to <a href="http://www.modssl.org/">download mod_ssl</a> to get the sign.sh script mentioned in the tutorial but that’s all you  need it for.  You’ll notice the mod_ssl site says it’s only for Apache  1.3.X.  That is because Apache2 has built in SSL  support which we enabled in the makefile configuration above so mod_ssl  is no longer needed.</li>
</ul>
</li>
<li>Edit your httpd.conf file: <code>sudo vi  /usr/local/apache2/conf/httpd.conf</code></li>
<li>Add the following configuration to the bottom of the file to proxy  all HTTP and HTTPS  requests to port 3000, i.e., Rails:
<ul>
<li>This assumes Rails is running on port 3000 on your machine</li>
<li>This assumes you put the SSL keys where  the tutorial told you to</li>
<li>The last  tag  might already be in your <code>httpd.conf</code> file, if so, no need to  repeat it here
<pre><code># Apache needs to know you want to accept connections over HTTPS
Listen 443

SSLCertificateFile /etc/httpd/ssl.key/server.crt
SSLCertificateKeyFile /etc/httpd/ssl.key/server.key

# Below is optional, but was helpful to me in debugging this setup
CustomLog logs/ssl_request_log  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" 

&lt;VirtualHost *:80&gt;
    ServerName localhost
    ServerAlias 127.0.0.1

    ProxyPass / &lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;
    ProxyPassReverse / &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;
    ProxyPreserveHost on

&lt;VirtualHost *:443&gt;
    SSLEngine On
    ServerName localhost
    ServerAlias 127.0.0.1

    ProxyPass / &lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;
    ProxyPassReverse / &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;
    ProxyPreserveHost on
    RequestHeader set X_FORWARDED_PROTO 'https'

&lt;ifmodule ssl_module&gt;
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
&lt;/ifmodule&gt;
</code></pre>
</li>
</ul>
</li>
</ol>
<h2>Auto-starting Apache</h2>
<p>If you’d like to have apache start automatically whenever your  computer starts do the following:</p>
<ol>
<li>Create a new plist file for apache with a unique name: <code>sudo  vi /Library/LaunchDaemons/org.apache.httpd</code></li>
<li>Put the following in the file (assuming you installed apache in <code>/usr/local/apache2</code>):
<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;KeepAlive&lt;/key&gt;
        &lt;true /&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;org.apache.httpd&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;/usr/local/apache2/bin/apachectl&lt;/string&gt;
            &lt;string&gt;start&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true /&gt;
        &lt;key&gt;UserName&lt;/key&gt;
        &lt;string&gt;root&lt;/string&gt;
        &lt;key&gt;WorkingDirectory&lt;/key&gt;
        &lt;string&gt;/usr/local/apache2&lt;/string&gt;
    &lt;/dict&gt;
&lt;/plist&gt;
</code></pre>
</li>
<li>Test it out with launchd: <code>sudo launchctl load -w  /Library/LaunchDaemons/org.apache.httpd</code>; You should see several  instances of <code>httpd</code> running if you do a: <code>ps aux | grep  httpd</code></li>
</ol>
<h2>Testing it out</h2>
<ol>
<li>Fire up Rails on whatever port you are forwarding your HTTP/HTTPS requests to</li>
<li>Request an action with HTTP</li>
<li>Request an action with HTTPS</li>
</ol>
<h2>Possible Problems</h2>
<p>I encountered the following cryptic error in FireFox when I was testing  out an Apache install on a second dev box:</p>
<p><code>SEC_ERROR_REUSED_ISSUER_AND_SERIAL</code></p>
<p>I found out by <a href="http://support.mozilla.com/tiki-view_forum_thread.php?comments_parentId=1519&amp;forumId=1">reading  through some forums</a> that each SSL  certificate needs to have a unique serial number.  Since I had followed  the above procedure to install Apache and SSL  on both my laptop and the second dev box I already had a certificate with the  same serial number stored in my browser (for my local machine) as the  one on the second dev box. If you follow the above process the serial number  of your certificate will be <code>01</code>.  So to fix this do the  following on your new certificate (for me it was the one on the dev box):</p>
<pre><code>sudo openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 02 -out server.crt
</code></pre>
<p>This simply assigns <code>02</code> to the second certificate and keeps  FireFox happy.  You probably will not encounter this problem unless you  are testing SSL on multiple machines like I  was but I figured I’d mention it anyways.  Note, you can see the serial  number of a certificate in FireFox by going to:</p>
<p><code>Firefox &gt; Preferences &gt; Advanced &gt; View Certificates (button)<br />
</code></p>
<p>Then double click on a certificate of interest.  Also note that Chrome  did not complain about this but FireFox won’t even let you visit a site  with a duplicate serial number.</p>
<h2>If you get stuck…</h2>
<p>Try one of the following resources that I used to get this up and  running:</p>
<ul>
<li><a href="http://www.subelsky.com/2007/11/testing-rails-ssl-requirements-on-your.html">Testing  SSL Requirements on Rails</a></li>
<li><a href="http://developer.apple.com/internet/serverside/modssl.html">Using  mod_ssl on Mac OS X</a></li>
<li><a href="http://support.mozilla.com/tiki-view_forum_thread.php?comments_parentId=1519&amp;forumId=1">Same  Serial Number of Certificate Error</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2010/03/installing-apache2-with-ssl-support-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installiing and Running MySQL 5.1 and MySQL 5.0 simultaneously on Mac OS X</title>
		<link>http://www.jasonfox.com/2010/03/installiing-and-running-mysql-5-1-next-to-5-0/</link>
		<comments>http://www.jasonfox.com/2010/03/installiing-and-running-mysql-5-1-next-to-5-0/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 23:51:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=223</guid>
		<description><![CDATA[

I am writing a few new applications and decided to upgrade to MySQL 5.1 from MySQL 5.0.  However, I have several legacy applications that still require MySQL 5.0.  So, I set out to get them both up and running side-by-side so I could forge a new path forward to 5.1 while not abandoning my 5.0 [...]]]></description>
			<content:encoded><![CDATA[<div id="OriginalPost">
<div>
<p>I am writing a few new applications and decided to upgrade to MySQL 5.1 from MySQL 5.0.  However, I have several legacy applications that still require MySQL 5.0.  So, I set out to get them both up and running side-by-side so I could forge a new path forward to 5.1 while not abandoning my 5.0 apps.</p>
<h2>Installing MySQL 5.1</h2>
<ol>
<li>Download the <strong>source</strong> distribution of the latest 5.1  (for me it was 5.1.42)</li>
<li>Decompress it and extract it into a directory</li>
<li>Create a new home for the 5.1 files, I put it in <code><strong>/usr/local/mysql-5.1.42</strong></code></li>
<li>Next <code>cd</code> into the directory where you extracted the  files</li>
<li>Run the following command substituting your install directory  created in step 3 above: <code>./configure --prefix=<strong>/usr/local/mysql-5.1.42</strong> --with-extra-charsets=complex --enable-thread-safe-client  --enable-local-infile --enable-shared --with-plugins=innobase</code></li>
<li>Compile the code by running: <code>make</code>; this will take a  few minutes (10ish?)</li>
<li>Install into your chosen directory with: <code>sudo make install</code></li>
<li>Next <code>cd</code> into your install directory: <code>cd <strong>/usr/local/mysql-5.1.42</strong></code></li>
<li>Create the mysql database with: <code>sudo ./bin/mysql_install_db  --user=mysql</code></li>
<li>Change ownership of the var directory (this is the data  directory): <code>sudo chown -R mysql ./var</code></li>
<li>Change ownership of the install directory: <code>sudo chown -R  mysql <strong>/usr/local/mysql-5.1.42</strong></code></li>
<li>Create a socket file in your install directory: <code>sudo -u  mysql touch mysql.sock</code>; mysql may create this itself on start-up,  but, I created it ahead of time</li>
<li>Start the server: <code>sudo -u mysql ./libexec/mysqld --basedir=<strong>/usr/local/mysql-5.1.42</strong> --port=6666 --socket=<strong>/usr/local/mysql-5.1.42/mysql.sock</strong> --user=mysql</code></li>
</ol>
<h2>Running MySQL 5.1 and 5.0</h2>
<ol>
<li>Edit your <code>my.cnf</code> file and explicitly add: <code>socket=/tmp/mysql.socket</code>;  if you do not do this when you start the 5.1 server the socket will be  deleted</li>
<li>Create a new <code>my.cnf</code> file in your 5.1 installation  root; for me: */usr/local/mysql-5.1.42/; your <code>my.cnf</code> file  should look like this:
<pre><code>    [mysqld]
    basedir=/usr/local/mysql-5.1.42/
    port=6666
    socket=/tmp/mysql.5.1.socket
    user=mysql
</code></pre>
</li>
<li>Change ownership of the <code>my.cnf</code> file to the <code>mysql</code> user: <code>sudo chown -R mysql my.cnf</code></li>
<li>Create a plist file for <code>launchd</code> called something  like: <code>com.mysql.mysqld.5.1.plist</code> in <code>/Library/LaunchDaemons</code>;  your plist file should look like this:
<pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
    &lt;plist version="1.0"&gt;
        &lt;dict&gt;
            &lt;key&gt;KeepAlive&lt;/key&gt;
            &lt;true /&gt;
            &lt;key&gt;Label&lt;/key&gt;
            &lt;string&gt;com.mysql.mysqld.5.1&lt;/string&gt;
            &lt;key&gt;ProgramArguments&lt;/key&gt;
            &lt;array&gt;
                &lt;string&gt;/usr/local/mysql-5.1.42/bin/mysqld_safe&lt;/string&gt;
                &lt;string&gt;--defaults-file=/usr/local/mysql-5.1.42/my.cnf&lt;/string&gt;
            &lt;/array&gt;
            &lt;key&gt;RunAtLoad&lt;/key&gt;
            &lt;true /&gt;
            &lt;key&gt;UserName&lt;/key&gt;
            &lt;string&gt;mysql&lt;/string&gt;
            &lt;key&gt;WorkingDirectory&lt;/key&gt;
            &lt;string&gt;/usr/local/mysql-5.1.42&lt;/string&gt;
        &lt;/dict&gt;
    &lt;/plist&gt;
</code></pre>
</li>
<li>Change ownership of the plist file to root like so: <code>sudo  chown root /Library/LaunchDaemons/com.mysql.mysqld.5.1.plist</code></li>
<li>Test it out by launching mysql: <code>sudo launchctl load -w  /Library/LaunchDaemons/com.mysql.mysqld.5.1.plist</code>; The next time  you start up both MySQL 5.0 and 5.1 should be started up.  Check the <code>/tmp</code> directory after start-up to ensure both sockets were created  successfully.</li>
</ol>
<h2>A few notes about this process</h2>
<ul>
<li>When you install from source the layout of the installation is  different than when you install from the binary distribution, i.e., the  data direectory is <code>var</code> not <code>data</code> and the server  binary is in <code>libexec</code> not <code>bin</code>, etc. For more  information check out <a href="http://dev.mysql.com/doc/refman/5.1/en/installation-layouts.html">this  article</a>.</li>
<li>When starting a second instance of mysqld you must specify  different values for the following options: <code>port</code>, <code>socket</code>,  <code>pid-file</code>, <code>tmpdir</code>, <code>datadir</code>.   However, if you specify the <code>basedir</code> you only need to  explicitly set values for <code>socket</code> and <code>port</code> as  we did in the last step above.  For more information check out <a href="http://dev.mysql.com/doc/refman/5.1/en/multiple-servers.html">this  article</a>.</li>
<li>When you start the mysql client you must specify the socket and  port like so: <code>/usr/local/mysql-5.1.42/bin/mysql -P 6666 -S  /usr/local/mysql-5.1.42/mysql.sock -u root</code>; Alternatively you can  create a hidden <code>.my.cnf</code> file in your home directory and  specify which server should be connected to by default when you run the  mysql client.  Your <code>.my.cnf</code> file should look like this:
<pre><code>    [client]
    port=6666
    socket=/tmp/mysql.5.1.socket
</code></pre>
</li>
</ul>
<h2><strong>Working with Rails</strong></h2>
<div>Now that you have two MySQL  servers running  you need to tell Rails which one you want to use in a  more explicit  fashion.  Here’s an example from my <code>database.yml</code> file:</div>
<pre><code>    # Main database connection for the media_service;
    # Uses MySQL 5.1
    development:
      adapter: mysql
      encoding: utf8
      database: my_development
      username: foo
      password: bar
      socket: /tmp/mysql.5.1.socket
      port: 6666</code></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2010/03/installiing-and-running-mysql-5-1-next-to-5-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>killall Dock &#8211; the most awesome command in the world</title>
		<link>http://www.jasonfox.com/2009/05/killall-dock-the-most-awesome-command-in-the-world/</link>
		<comments>http://www.jasonfox.com/2009/05/killall-dock-the-most-awesome-command-in-the-world/#comments</comments>
		<pubDate>Mon, 18 May 2009 20:58:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[expose]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=178</guid>
		<description><![CDATA[Ever have Expose freeze up on you? Command-TAB stops working, Spaces stops working, the Dock stops working, show desktop stops working, show windows stops working; you&#8217;re trapped!  Well, if you happen to have a terminal window open or can launch one, fear not!  Simply issue the following command (make sure to use a capital &#8216;D&#8217;) [...]]]></description>
			<content:encoded><![CDATA[<p>Ever have Expose freeze up on you? Command-TAB stops working, Spaces stops working, the Dock stops working, show desktop stops working, show windows stops working; you&#8217;re trapped!  Well, if you happen to have a terminal window open or can launch one, fear not!  Simply issue the following command (make sure to use a capital &#8216;D&#8217;) and you&#8217;re golden.  No restart required!</p>
<pre>$ killall Dock</pre>
<p>Share and enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/05/killall-dock-the-most-awesome-command-in-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backgroundjob (Bj) Won&#8217;t Start</title>
		<link>http://www.jasonfox.com/2009/05/backgroundjob-bj-wont-start/</link>
		<comments>http://www.jasonfox.com/2009/05/backgroundjob-bj-wont-start/#comments</comments>
		<pubDate>Fri, 15 May 2009 13:46:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[backgroundjob]]></category>
		<category><![CDATA[bj]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=171</guid>
		<description><![CDATA[Recently I had a problem with Bj where it would not start up.  Nothing was written to the backgroundjob log or Rails log and no exception was being thrown.  To make the problem even stranger, Bj would start-up just fine in development but not in production but worked just fine in production from script/console.  After [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a problem with <a href="http://agilewebdevelopment.com/plugins/bj">Bj</a> where it would not start up.  Nothing was written to the backgroundjob log or Rails log and no exception was being thrown.  To make the problem even stranger, Bj would start-up just fine in development but not in production but worked just fine in production from script/console.  After digging into the Bj code and adding some debug statements I found the problem.</p>
<pre># database.yml
development:
  adapter: mysql
  database: my_development
  username: me
  password: password
  host: localhost
  port: 3306

test:
  adapter: mysql
  database: my_test
  username: me
  password: password
  host: localhost
  port: 3306

production:
  development</pre>
<p>Bj was getting an ActiveRecord::ConnectionNotEstablished exception but was swallowing it.  The solution was to explicitly define the production database connection in database.yml.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/05/backgroundjob-bj-wont-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>acts_as_universally_unique</title>
		<link>http://www.jasonfox.com/2009/03/acts_as_universally_unique/</link>
		<comments>http://www.jasonfox.com/2009/03/acts_as_universally_unique/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 17:40:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[uuid]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=142</guid>
		<description><![CDATA[I recently found the need to provide UUIDs for ActiveRecord models in a service that I&#8217;m developing.  I wasn&#8217;t able to find a suitable soution, so, I rolled my own.  Enter acts_as_universally_unique.  The plugin simply adds a (customizabe) UUID field to all ActiveRecord models that act_as_universally_unique.  I will be adding additional methods (and test cases) [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found the need to provide UUIDs for ActiveRecord models in a service that I&#8217;m developing.  I wasn&#8217;t able to find a suitable soution, so, I rolled my own.  Enter <a href="http://github.com/jfoxny/acts_as_universally_unique/tree/master">acts_as_universally_unique</a>.  The plugin simply adds a (customizabe) UUID field to all ActiveRecord models that act_as_universally_unique.  I will be adding additional methods (and test cases) to it shortly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/03/acts_as_universally_unique/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML-RPC, SOAP and Polymorphism</title>
		<link>http://www.jasonfox.com/2009/02/xml-rpc-soap-and-polymorphism/</link>
		<comments>http://www.jasonfox.com/2009/02/xml-rpc-soap-and-polymorphism/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 01:40:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[polymorphism]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=113</guid>
		<description><![CDATA[According to the XML-RPC specification a XML_RPC request may only contain scalar &#60;value&#62;s or non-scalar &#60;struct&#62;s. The specification unfortunately does not provide any standard for encoding the type of data encoded in the &#60;struct&#62;s. This has the side effect of not being able to support polymorphism in service method parameters as it leaves the sever [...]]]></description>
			<content:encoded><![CDATA[<p>According to the <a href="http://www.xmlrpc.com/spec">XML-RPC specification</a> a XML_RPC request may only contain scalar &lt;value&gt;s or non-scalar &lt;struct&gt;s. The specification unfortunately does not provide any standard for encoding the type of data encoded in the &lt;struct&gt;s. This has the side effect of not being able to support polymorphism in service method parameters as it leaves the sever no choice but to rely on the method signature in the API declaration when trying to determine what to instantiate for a given &lt;struct&gt; in the XML-RPC request.</p>
<p>Let&#8217;s say you have the following declarations:</p>
<pre>class SubscriptionsApi &lt; ActionWebService::API::Base
  api_method(
    :create_subscription,
    :expects =&gt; [
      { :customer =&gt; Logical::Customer },
      { :payment_method =&gt; Logical::PaymentMethod }
    ]
  )
end
module Logical
  class PaymentMethod &lt; ActionWebService::Struct
  end
  class CreditCard &lt; PaymentMethod
    member :card_number, :string
    # ...
  end
  class PayPal &lt; PaymentMethod
    member :login, :string
    # ...
  end
end</pre>
<p>Now you want to make a call to the service method and pass either a CreditCard or a PayPal. XML-RPC will encode the request like so:</p>
<pre>&lt;methodCall&gt;
  &lt;methodName&gt;create_subscription&lt;/methodName&gt;
  &lt;param&gt;
    &lt;struct&gt;
      &lt;member&gt;
        &lt;name&gt;card_number&lt;/name&gt;
        &lt;value&gt;4111-1111-1111-1111&lt;/value&gt;
      &lt;/member&gt;
    &lt;/struct&gt;
  &lt;/param&gt;
&lt;/methodCall&gt;</pre>
<p>This provides no type information to the server so the server will attempt to instantiate a Logical::PaymentMethod which will of course not have a card_number member as it&#8217;s specific to the CreditCard subclass. SOAP, on the other hand, does encode the parameter types allowing you to utilize this type of polymorphism in your service parameters. Here&#8217;s the same request encoded in SOAP.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;env:Body&gt;
  &lt;n1:CreateSubscription xmlns:n1="urn:ActionWebService" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
    &lt;payment_method xmlns:n2="http://www.ruby-lang.org/xmlns/ruby/type/custom" xsi:type="n2:Logical..CreditCard"&gt;
      &lt;card_number xsi:type="xsd:string"&gt;1&lt;/card_number&gt;
    &lt;/payment_method&gt;
  &lt;/n1:CreateSubscription&gt;
 &lt;/env:Body&gt;
&lt;/env:Envelope&gt;</pre>
<p>The <a href="http://github.com/jfoxny/actionwebservice/tree/master">current implementation</a> of ActionWebService resurrected by <a href="http://www.datanoise.com/articles/2008/7/2/actionwebservice-is-back">datanoise</a> did not support this type of polymorphism in SOAP requests. However, <a href="http://github.com/jfoxny.atom">I submitted a patch</a> recently which provides for this functionality. Hopefully it&#8217;s accepted. <img src='http://www.jasonfox.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/02/xml-rpc-soap-and-polymorphism/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL Allows NULLs Where They Are Not Welcome</title>
		<link>http://www.jasonfox.com/2009/02/mysql-allows-nulls-where-they-are-not-allowed/</link>
		<comments>http://www.jasonfox.com/2009/02/mysql-allows-nulls-where-they-are-not-allowed/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 18:18:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=94</guid>
		<description><![CDATA[I recently came across an annoying bug in MySQL v5.1 (also in 6.0 apparently) that bit me hard, so, I thought I&#8217;d post on it in case you are being bitten by the same bug.
If you attempt to update a column that does not allow NULL to NULL, MySQL will set the column&#8217;s value to [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across an annoying bug in MySQL v5.1 (also in 6.0 apparently) that bit me hard, so, I thought I&#8217;d post on it in case you are being bitten by the same bug.</p>
<p>If you attempt to update a column that does not allow NULL to NULL, MySQL will set the column&#8217;s value to the default value for that column&#8217;s data type.  This is true only when you are not running MySQL <a href="http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_trans_tables">strict mode</a>.  Here&#8217;s an example to illustrate.</p>
<pre>mysql&gt; create table null_test (id int not null unique(id), name varchar(25)
null default null);
Query OK, 0 rows affected (0.01 sec)

mysql&gt; show create table null_test;
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table     | Create Table                                                                                                                                           |
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| null_test | CREATE TABLE `null_test` (
  `id` int(11) NOT NULL,
  `name` varchar(25) default NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql&gt; insert into null_test (id, name) values (1, 'Jane');
Query OK, 1 row affected (0.00 sec)

mysql&gt; update null_test set id = null;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql&gt; select * from null_test where name = 'Jane';
+----+------+
| id | name |
+----+------+
|  0 | Jane |
+----+------+
1 row in set (0.00 sec)</pre>
<p>More information about this bug can be found in the <a href="http://bugs.mysql.com/bug.php?id=33699">bug report</a> submitted Janurary 4, 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/02/mysql-allows-nulls-where-they-are-not-allowed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Constraints and MySQL</title>
		<link>http://www.jasonfox.com/2009/02/check-constraints-and-mysql/</link>
		<comments>http://www.jasonfox.com/2009/02/check-constraints-and-mysql/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 00:47:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=80</guid>
		<description><![CDATA[Unfortunately, MySQL does not support check constraints out of the box.  This makes the task of enforcing business logic in the database layer difficult, but not impossible.  ]]></description>
			<content:encoded><![CDATA[<div class="discussion">
<p class="description">Unfortunately, MySQL does not support <a href="http://en.wikipedia.org/wiki/Check_Constraint">check constraints</a> out of the box.  This makes the task of enforcing business logic in the database layer difficult, but not impossible.  I recently found <a href="http://forge.mysql.com/wiki/Triggers#Emulating_Check_Constraints">this approach</a> to implementing check constraints in MySQL.  It&#8217;s not as pretty and clean as I&#8217;d like, but, it&#8217;s the best approach that I&#8217;ve found so far.</p>
<p>Now. why would you want to encode business logic in the database?  Can&#8217;t you make due with your <a href="http://api.rubyonrails.com/classes/ActiveRecord/Validations.html">ActiveRecord::Validations</a>?</p>
<p>Well, have you ever updated the database directly?  Have you ever called update_attribute on an object?  How about save_with_validation(false)?   Yeah, I thought so.  Read more about why you should treat your database as a fortress in <a href="http://blog.chak.org/">Dan Chak</a>&#8217;s recently released book, <a href="http://www.amazon.com/Enterprise-Rails-Dan-Chak/dp/0596515200/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1233881182&amp;sr=8-1">Enterprise Rails</a> (review coming soon).</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/02/check-constraints-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rewriting Sub-selects as Joins</title>
		<link>http://www.jasonfox.com/2009/02/rewriting-sub-selects-as-joins/</link>
		<comments>http://www.jasonfox.com/2009/02/rewriting-sub-selects-as-joins/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 23:07:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.jasonfox.com/?p=68</guid>
		<description><![CDATA[Your RDBMS will usually rewrite your sub-selects behind the scenes as joins.  However, there are times where you'll want to do this yourself. Here are a couple examples of how to rewrite sub-selects as joins.]]></description>
			<content:encoded><![CDATA[<p>Your RDBMS will usually rewrite your sub-selects behind the scenes as joins.  However, there are times where you&#8217;ll want to do this yourself.  For example, past versions of MySQL did not play well with sub-selects.  Here are a couple examples of how to rewrite sub-selects as joins.</p>
<pre>select *
from   table_a
where  id not in (select a_id from table_b);
<strong>-- can be rewritten as...
</strong>select *
from   table_a
left   outer join table_b on table_a.id = table_b.a_id
where  table_b.a_id is null;

select *
from   table_a
where  id in (select a_id from table_b);
<strong>-- can be rewritten as...</strong>
select *
from   table_a
left outer join table_b on table_a.id = table_b.a_id
where  table_b.a_id is not null;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonfox.com/2009/02/rewriting-sub-selects-as-joins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
