<?xml version="1.0" encoding="UTF-8"?>
<posts type="array">
  <post>
    <author>Simon Schoeters</author>
    <content>&lt;p&gt;It took me a while to figure out the differences between the AddHandler and AddType directives in an Apache configuration. Both directives seem to define how the contents of a file with a given extension should be threatened but when do you need the first one and when the second?&lt;/p&gt;

&lt;p&gt;Turned out it isn't too hard... the AddType handler specifies how the &lt;strong&gt;client&lt;/strong&gt; (think about a browser) has to deal with a particular data stream (e.g. download a binary or show an image or HTML page). The AddHandler on the other hand maps a handler to the file extension telling the &lt;strong&gt;server&lt;/strong&gt; what to do with it. So if you are defining a Ruby on Rails or PHP content type you will need the AddHandler, telling the server it should parse the file. If you define a JavaScript or HTML file you will need the AddType one to tell the browser what content type to expect.&lt;/p&gt;

&lt;h3&gt;Strict versus quirks mode&lt;/h3&gt;

&lt;p&gt;Something slightly related is how browsers actually deal with the content type you set in your AddType directive. Gecko based browsers (like Firefox) follow the standard closely so they will handle a file according to the content type in your Apache configuration. This means your image will show up as text if you wrongly assigned the text/plain content type. Internet Explorer is more flexible and tries to guess the mime type for misconfigured web servers showing a wrongly defined images as, well, an image.&lt;/p&gt;

&lt;h3&gt;More resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://httpd.apache.org/docs/2.0/mod/mod_mime.html" title="Apache Module mod_mime documentation" class="ext"&gt;Apache's Module mod_mime documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.mozilla.org/en/docs/Properly_Configuring_Server_MIME_Types" title="Properly Configuring Server MIME Types at the Mozilla Developer Center" class="ext"&gt;Properly Configuring Server MIME Types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.mozilla.org/en/docs/Properly_Configuring_Server_MIME_Types" title="A sample .htaccess file at the Mozilla Developer Center" class="ext"&gt;A sample .htaccess file with common MIME types&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
    <created-at type="datetime">2007-09-05T15:10:08+02:00</created-at>
    <id type="integer">2</id>
    <location-id type="integer">3</location-id>
    <permalink>addhandler-addtype-directives</permalink>
    <title>Apache AddHandler or AddType directive?</title>
    <updated-at type="datetime">2007-10-07T01:59:19+02:00</updated-at>
  </post>
  <post>
    <author>Simon Schoeters</author>
    <content>&lt;p&gt;After upgrading Ruby to 1.8.6 and Rails to 2.0.2 I ran intro problems with my installed gems. My application couldn't find any of the installed gems anymore! The &lt;samp&gt;gem list&lt;/samp&gt; command returned the installed gems like you would expect and even the &lt;samp&gt;./script/console&lt;/samp&gt; environment in my Rails application found the gems I needed but requiring a gem in one of my controllers like:&lt;/p&gt;

&lt;p&gt;&lt;samp&gt;require 'somegem'&lt;/samp&gt;&lt;/p&gt;

&lt;p&gt;returned the following error:&lt;/p&gt;

&lt;p&gt;&lt;samp&gt;MissingSourceFile (no such file to load -- somegem)&lt;/samp&gt;&lt;/p&gt;

&lt;p&gt;It took ages to find out what the problem was. My &lt;a href="http://www.rubygems.org/read/chapter/3#page83" title="Installing RubyGems in a User Directory" class="ext"&gt;GEM_PATH&lt;/a&gt; variable - this is where RubyGems looks for the installed gems - was set. I could find the gem from everywhere, except from within the controllers in my application. However, it did work fine when I ran the WEBrick server but when using my LightTPD production server everything went fubar.&lt;/p&gt;

&lt;p&gt;Turned out I forgot to tell LightTPD to use the new GEM_PATH, other than the default one. You can do this in the LightTPD configuration file. Maybe I changed the gem installation directory as I build RubyGems from source without knowing? Add the following to your LightTPD configuration file (change the paths where needed) and reload the server.&lt;/p&gt;

&lt;p&gt;&lt;samp&gt;fastcgi.server =&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;".fcgi" =&amp;gt;&lt;br /&gt;
&amp;nbsp;(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;"localhost" =&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"min-procs" =&amp;gt; 1,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"max-procs" =&amp;gt; 1,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"socket" =&amp;gt; "&amp;lt;app&amp;gt;/tmp/sockets/fcgi.socket",&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"bin-path" =&amp;gt; "&amp;lt;app&amp;gt;/public/dispatch.fcgi",&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"bin-environment" =&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"RAILS_ENV" =&gt; "production",&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;"GEM_PATH" =&gt; "/usr/local/lib/ruby/gems/1.8/"&lt;/strong&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;)&lt;br /&gt;
&amp;nbsp;)&lt;br /&gt;
)&lt;/samp&gt;&lt;/p&gt;

&lt;p&gt;That's it, Suffix is now happily running the latest Ruby on Rails version.&lt;/p&gt;</content>
    <created-at type="datetime">2008-02-29T10:07:22+01:00</created-at>
    <id type="integer">20</id>
    <location-id type="integer">3</location-id>
    <permalink>missing-gems-in-lighttpd</permalink>
    <title>Missing gems in LightTPD</title>
    <updated-at type="datetime">2008-03-03T00:11:49+01:00</updated-at>
  </post>
  <post>
    <author>Simon Schoeters</author>
    <content>&lt;p&gt;&lt;a href="http://drupal.org/" title="Official Drupal website" class="ext"&gt;Drupal&lt;/a&gt; supports multi-sites, this means you can install Drupal once and use it for multiple websites (also known as single codebase). This kind of setup will make it easier to maintain your Drupal installation or when you want to upgrade to a newer version as you only need to maintain one codebase.  The most common setup seems the subdomain aproach: each website uses its own subdomain. Suppose you want websites for different projects. The layouts and requirements may be different but they will all run on Drupal. The URL's will look like this:&lt;/p&gt;

&lt;samp&gt;http://project1.example.com&lt;br /&gt;
http://project2.example.com&lt;/samp&gt;

&lt;p&gt;There are tons of &lt;a href="http://drupal.org/node/43816" title="Drupal multi-site installation and set-up" class="ext"&gt;tutorials&lt;/a&gt; on the Drupal site to create this setup but that's not what we are looking for. We want a setup with multiple websites in subdirectories, not subdomains:&lt;/p&gt;

&lt;samp&gt;http://www.example.com/project1&lt;br /&gt;
http://www.example.com/project2&lt;/samp&gt;

&lt;p&gt;It's a little harder (really only a little) to find how to get this done, let's have a look.&lt;/p&gt;

&lt;h3&gt;Install Drupal&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Start with installing Drupal as you would normally do. Download the latest version and extract it in your server's document root (probably &amp;lsquo;/var/www/html&amp;rsquo;).&lt;/li&gt;
&lt;li&gt;Create a database and database user for this installation but call it something like &amp;lsquo;&lt;samp&gt;project1&lt;/samp&gt;&amp;rsquo; as this will be the database for the first project.&lt;/li&gt;
&lt;li&gt;Configure your installation via the web interface.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it, you have your first installation up and running, nothing new here.&lt;/p&gt;

&lt;h3&gt;Add another instance&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a second database and call it &amp;lsquo;&lt;samp&gt;project2&lt;/samp&gt;&amp;rsquo;. You can use the same user as for the first database but it's obvious that this would be a very bad choice for security reasons.&lt;/li&gt;
&lt;li&gt;Make a copy of the database for the second project (add the -u and -p parameters twice if needed).&lt;br /&gt;
&lt;samp&gt;mysqldump --opt project1 | mysql -h localhost project2&lt;/samp&gt;&lt;/li&gt;
&lt;li&gt;Now create the folder structure in your &lt;samp&gt;&amp;lt;docroot&amp;gt;/sites&lt;/samp&gt; directory as explained &lt;a href="http://drupal.org/node/53705" title="Setup of /sites directory for multi-site" class="ext"&gt;here&lt;/a&gt;. Be careful not to call the directories &amp;lsquo;example1.com&amp;rsquo; and &amp;lsquo;example2.com&amp;rsquo; as explained in the document but:&lt;br /&gt;
&lt;samp&gt;example.com.project1&lt;br /&gt;
example.com.project2&lt;/samp&gt;&lt;/li&gt;
&lt;li&gt;And now the magic... add symlinks for each project in your document root:&lt;br /&gt;
&lt;samp&gt;ln -s &amp;lt;docroot&amp;gt; project1&lt;br /&gt;
ln -s &amp;lt;docroot&amp;gt; project2&lt;/samp&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now point your browser to http://www.example.com/project1 and you should see the first site, http://www.example.com/project2 will get you to the second one. At this point both sites will be identical (you copied the database remember?) but you can start changing the contents independently of each other now.&lt;/p&gt;</content>
    <created-at type="datetime">2008-10-14T09:30:14+02:00</created-at>
    <id type="integer">38</id>
    <location-id type="integer">8</location-id>
    <permalink>drupal-multi-site</permalink>
    <title>Drupal multi-site without subdomains</title>
    <updated-at type="datetime">2009-01-28T16:55:55+01:00</updated-at>
  </post>
  <post>
    <author>Simon Schoeters</author>
    <content>&lt;p&gt;When you have multiple Macs &amp;ndash; like your laptop and a desktop computer or home and office computer &amp;ndash; it's hard to access your files from another computer. Ever tried mailing files to yourself? &lt;a href="http://www.dropbox.com/" class="ext" title="Download Dropbox"&gt;Dropbox&lt;/a&gt; is a free application that synchronizes files immediately to all your computers over the intertubes. You can even access the files via their website.&lt;/p&gt;

&lt;h3&gt;Sync application data&lt;/h3&gt;

&lt;p&gt;So far so good but what to do with application data like your contacts in Address Book, your &lt;a href="http://culturedcode.com/things/" class="ext" title="Task management application for Mac"&gt;Things&lt;/a&gt; to do list, your &lt;a href="http://www.wonderwarp.com/shovebox/" class="ext" title="A clutter-catcher: store information sc'raps in the menu bar"&gt;ShoveBox&lt;/a&gt; notes or anything else with a database for that matter? Symlinking is the answer!&lt;/p&gt;

&lt;p&gt;You can't sync a folder outside of the Dropbox folder and all these application databases live, well, outside of the Dropbox folder. Most applications store their data in the Library folder (in /Library/Application&amp;nbsp;Support/ or ~/Library/Application&amp;nbsp;Support/). The trick is to move the databases to your Dropbox folder while the application still thinks it's somewhere in your Mac's Library folder.&lt;/p&gt;

&lt;p&gt;We'll need some command line stuff to get this done so &lt;strong&gt;backup your data&lt;/strong&gt;. I'll say this once more and still you won't listen but, please &lt;strong&gt;BACKUP&lt;/strong&gt; your data before doing this.&lt;/p&gt;

&lt;h3&gt;Moving data&lt;/h3&gt;

&lt;p&gt;I'll use the Address Book library as an example. Close Address Book first! Drag the folder with the application data (~/Library/Application Support/AddressBook) to some Dropbox folder (e.g. ~/Dropbox/ApplicationSupport/AddressBook). You can choose the name of the destination directory the way you want.&lt;/p&gt; 

&lt;p&gt;At this moment Dropbox will be syncing your Address Book data to all your computers with Dropbox installed. Great, but we still need to trick Address Book as we moved its database. Let's create a symbolic link from the old location to the new Dropbox folder. In Terminal:&lt;/p&gt;

&lt;samp&gt;cd ~/Library/Application\ Support/&lt;br /&gt;
ln -s ~/Dropbox/ApplicationSupport/AddressBook/ AddressBook
&lt;/samp&gt;

&lt;p&gt;You created a link from the old location to the new one. You should see the little Dropbox status icon on the folder in your ~/Library/Application&amp;nbsp;Support folder. That's good. Open Address Book and check to see if all your contacts are still there. Yes? Good, now create a similar link on your other computer (don't forget to close Address Book). I simply removed the Address Book library on my other computer... the whole purpose is to have the same data on both computers off course but please make sure there is nothing important there.&lt;/p&gt;

&lt;h3&gt;What's not cool&lt;/h3&gt;

&lt;p&gt;I wouldn't run both applications at the same time, you'll probably screw up your data! Address Book doesn't know it's using a &amp;lsquo;shared&amp;rsquo; library so if both applications want to write changes at the same time things will go foobar.&lt;/p&gt;

&lt;h3&gt;Other applications&lt;/h3&gt;

&lt;p&gt;I see no reason why this wouldn't work for other applications. I'm happily using this method for Address Book, Things, ShoveBox and Little Snapper.&lt;/p&gt;</content>
    <created-at type="datetime">2009-11-18T19:37:37+01:00</created-at>
    <id type="integer">63</id>
    <location-id type="integer">8</location-id>
    <permalink>sync-data-dropbox</permalink>
    <title>Sync data with Dropbox</title>
    <updated-at type="datetime">2009-11-19T16:39:44+01:00</updated-at>
  </post>
</posts>
