<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Missing Readme</title>
	<atom:link href="http://missingreadme.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://missingreadme.wordpress.com</link>
	<description>Because the coolest things are never in the manual</description>
	<lastBuildDate>Tue, 22 Mar 2011 02:07:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='missingreadme.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Missing Readme</title>
		<link>http://missingreadme.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://missingreadme.wordpress.com/osd.xml" title="The Missing Readme" />
	<atom:link rel='hub' href='http://missingreadme.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to connect to MySQL in PHP on Mac OS X</title>
		<link>http://missingreadme.wordpress.com/2011/03/18/how-to-connect-to-mysql-in-php-on-mac-os-x/</link>
		<comments>http://missingreadme.wordpress.com/2011/03/18/how-to-connect-to-mysql-in-php-on-mac-os-x/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 04:23:30 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=144</guid>
		<description><![CDATA[Enabling PHP on Mac OS X is pretty straightforward (it&#8217;s preinstalled from OS X 10.5 onwards): Uncomment LoadModule php5_module in /etc/apache2/httpd.conf Start up Web Sharing in System Preferences However, even after doing that, my PHP-based website still couldn&#8217;t connect to it&#8217;s MySQL database. It just showed this error when I tried to load the site: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=144&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Enabling PHP on Mac OS X is pretty straightforward (it&#8217;s preinstalled from OS X 10.5 onwards):</p>
<ol>
<li>Uncomment <tt>LoadModule php5_module</tt> in <tt>/etc/apache2/httpd.conf</tt></li>
<li>Start up Web Sharing in System Preferences</li>
</ol>
<p>However, even after doing that, my PHP-based website still couldn&#8217;t connect to it&#8217;s MySQL database. It just showed this error when I tried to load the site:<br />
<code><br />
Database Error: Unable to connect to the Database: Could not connect to MySQL.<br />
</code><br />
All of the database settings in my app (a Joomla website) were correct, but still I couldn&#8217;t get it to work.</p>
<p>It turns out that the problem is due to conflicting socket locations between OS X and other types of UNIX. In my case PHP was configured to access MySQL (locally) at <tt>/var/mysql/mysql.sock</tt> whereas the socket was really at <tt>/tmp/mysql.sock</tt>. Changing this in the PHP config fixed the problem</p>
<h3>Solution</h3>
<p>Create a custom PHP settings file:<br />
<code><br />
sudo cp /etc/php.ini.default /etc/php.ini<br />
</code><br />
then edit the <tt>default_socket</tt> definition for your database driver to point to the correct socket.In my case the driver is the default MySQL driver and the correct socket is <tt>/tmp/mysql.sock</tt>, so it changed from this:<br />
<code><br />
; Default socket name for local MySQL connects.  If empty, uses the built-in<br />
; MySQL defaults.<br />
; http://php.net/mysql.default-socket<br />
mysql.default_socket = /var/mysql/mysql.sock<br />
</code><br />
to this:<br />
<code><br />
; Default socket name for local MySQL connects.  If empty, uses the built-in<br />
; MySQL defaults.<br />
; http://php.net/mysql.default-socket<br />
mysql.default_socket = /tmp/mysql.sock<br />
</code><br />
It&#8217;s important to note that there will be several definitions of <tt>default_socket</tt> for different drivers (each of which has a different prefix for it&#8217;s settings) so it&#8217;s important that you change the correct one, based on what your app is using.</p>
<p>After doing this restart Web Sharing (in System Preferences) and everything should work</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=144&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2011/03/18/how-to-connect-to-mysql-in-php-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to write a custom gatherer/texthandler for RCurl</title>
		<link>http://missingreadme.wordpress.com/2011/02/08/how-to-write-a-custom-gatherer-for-rcurl/</link>
		<comments>http://missingreadme.wordpress.com/2011/02/08/how-to-write-a-custom-gatherer-for-rcurl/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 02:59:53 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Curl]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=135</guid>
		<description><![CDATA[The RCurl package for R allows you to download files from the internet &#8211; very useful if you want to make your analysis completely reproducible (yet you rely on files that have to be downloaded) or if the source data can change over time. Using the getURL() function you can download any file by it&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=135&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://cran.r-project.org/web/packages/RCurl/index.html">RCurl</a> package for R allows you to download files from the internet &#8211; very useful if you want to make your analysis completely reproducible (yet you rely on files that have to be downloaded) or if the source data can change over time.</p>
<p>Using the <tt>getURL()</tt> function you can download any file by it&#8217;s URL. What makes this even more useful is that you can give it a vector of URLs, and it will download them in parallel (by performing asynchronous downloads), and returning the results in a vector of the same length as the original.</p>
<p>But what if the file to be downloaded is large, but you&#8217;re only interested in a small part of it? That&#8217;s where gatherers come in. If you provide a gatherer (S3-style) object to the <tt>write</tt> parameter of the <tt>getURL()</tt> function, this object will be called whenever data is downloaded from one of the input URLs. That&#8217;s a great feature, but unfortunately it&#8217;s not well documented.</p>
<h3>Solution</h3>
<h4>1. Gatherer Objects</h4>
<p>Below is a constructor for a very simple gatherer that just returns a string of the contents of the downloaded file. This could be adapted to do more complex things.</p>
<pre>
SimpleGatherer &lt;- function(txt=character()){
  # SimpleGatherer is a constructor function that returns a new
  # gatherer object. txt is the variable that stores the contents of the
  # downloaded file
  #
  # This code is heavily based on basicTextGatherer() from RCurl

  reset &lt;- function(){
    # reset() is called when the gatherer is first created. It initialises txt
    txt &lt;&lt;- character()
  }
  update &lt;- function(str){
    # update() is called whenever new data is downloaded. Here it appends it
    # to txt
    txt &lt;&lt;- paste(txt, str, sep=&quot;&quot;)
  }
  value &lt;- function(){
    # value() is called when we want the result
    return(txt)
  }

  # gatherer is the new gatherer object that we want to return
  gatherer &lt;- list(reset=reset, update=update, value=value)
  class(gatherer) &lt;- c(&quot;RCurlTextHandler&quot;, &quot;RCurlCallbackFunction&quot;)
  gatherer$reset()

  return(gatherer)
}
</pre>
<p>Then call <tt>getURL()</tt> with the <tt>write</tt> argument set to an instance of your new gatherer object, eg:</p>
<pre>
getURL("http://missingreadme.wordpress.com/", write=SimpleGatherer())
</pre>
<h4>2. Asynchronous Gatherer Objects</h4>
<p>In order to use a custom gatherer for parallel/asynchronous downloads, you must create a custom gatherer object containing one gatherer object for each of your URLS, like this:</p>
<pre>
SimpleAsyncGatherer &lt;- function(n){
  # n is the number of URLs you&#039;re downloading
  gatherer &lt;- lapply(1:n, SimpleGatherer)
  class(gatherer) &lt;- &quot;MultiTextGatherer&quot;
  return(gatherer)
}
</pre>
<p>Note that if you don&#8217;t specify a custom gatherer using <tt>write</tt>, <tt>getURL</tt> automatically creates an asynchronous gatherer for you using the default gatherer object (<tt>basicTextGatherer()</tt>).</p>
<p>Use this gatherer as you would before, but with multiple URLs.</p>
<pre>
getURL(rep("http://missingreadme.wordpress.com/", 5), write=SimpleAsyncGatherer(5))
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=135&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2011/02/08/how-to-write-a-custom-gatherer-for-rcurl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to see the code for S4 methods in R</title>
		<link>http://missingreadme.wordpress.com/2011/01/04/how-to-see-the-code-for-s4-methods-in-r/</link>
		<comments>http://missingreadme.wordpress.com/2011/01/04/how-to-see-the-code-for-s4-methods-in-r/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 04:41:43 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=129</guid>
		<description><![CDATA[If you want to see the code for an S3 method (the older-style) in R it&#8217;s easy, you just need to type in the name of the method (with no brackets or parameters): &#62; ls function (name, pos = -1, envir = as.environment(pos), all.names = FALSE, pattern) { if (!missing(name)) { nameValue &#60;- try(name) if [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=129&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you want to see the code for an S3 method (the older-style) in R it&#8217;s easy, you just need to type in the name of the method (with no brackets or parameters):</p>
<pre>
&gt; ls
function (name, pos = -1, envir = as.environment(pos), all.names = FALSE,
    pattern)
{
    if (!missing(name)) {
        nameValue &lt;- try(name)
        if (identical(class(nameValue), &quot;try-error&quot;)) {
            name &lt;- substitute(name)
            if (!is.character(name))
                name &lt;- deparse(name)
            pos &lt;- name
        }
        else pos &lt;- nameValue
    }
    all.names &lt;- .Internal(ls(envir, all.names))
    if (!missing(pattern)) {
        if ((ll &lt;- length(grep(&quot;[&quot;, pattern, fixed = TRUE))) &amp;&amp;
            ll != length(grep(&quot;]&quot;, pattern, fixed = TRUE))) {
            if (pattern == &quot;[&quot;) {
                pattern &lt;- &quot;\\[&quot;
                warning(&quot;replaced regular expression pattern &#039;[&#039; by  &#039;\\\\[&#039;&quot;)
            }
            else if (length(grep(&quot;[^\\\\]\\[&lt;-&quot;, pattern))) {
                pattern &lt;- sub(&quot;\\[&lt;-&quot;, &quot;\\\\\\[&lt;-&quot;, pattern)
                warning(&quot;replaced &#039;[&lt;-&#039; by &#039;\\\\[&lt;-&#039; in regular expression pattern&quot;)
            }
        }
        grep(pattern, all.names, value = TRUE)
    }
    else all.names
}
</pre>
<p>and the code for that method will be printed on the screen.</p>
<p>However, if you try the same thing on an S4 method (the newer, object-oriented style) then you get something more obtuse:</p>
<pre>
&gt; # load the package I'm currently using (from bioconductor)
&gt; library("Rsamtools")
Loading required package: IRanges

Attaching package: 'IRanges'

The following object(s) are masked from 'package:base':

    cbind, Map, mapply, order, paste, pmax, pmax.int, pmin, pmin.int, rbind, rep.int, table

Loading required package: GenomicRanges
Loading required package: Biostrings
&gt; readPileup
standardGeneric for "readPileup" defined from package "Rsamtools"

function (file, ...)
standardGeneric("readPileup")

Methods may be defined for arguments: file
Use  showMethods("readPileup")  for currently available ones.
</pre>
<p>However, this makes sense if you consider how S4 works. Because it allows method overloading, there could be multiple method definitions depending on the parameters given to the method at runtime (it&#8217;s signature). So to get correct method definition, you need to specify the signature as well.</p>
<h3>Solution</h3>
<p>Use <tt>showMethod</tt> to show all of method signatures that are defined for the method in question, and <tt>getMethod</tt> to retrieve the code for a particular method and signature:</p>
<pre>
&gt; showMethods("readPileup")
Function: readPileup (package Rsamtools)
file="character"
file="connection"
</pre>
<p>Here we can see that for <tt>readPileup</tt> there are two method definitions, one with signature <tt>"character"</tt> and one with signature <tt>"connection"</tt>. Then if you call <tt>getMethod</tt> for one of these signatures you will be able to see the code:</p>
<pre>
&gt; getMethod("readPileup", "connection")
Method Definition:

function (file, ...)
{
    .local &lt;- function (file, ..., variant = c(&quot;SNP&quot;, &quot;indel&quot;,
        &quot;all&quot;))
    {
        variant &lt;- match.arg(variant)
        switch(variant, SNP = , all = .readPileup_SNP(file = file,
            ..., variant = variant), indel = .readPileup_indel(file = file,
            ...))
    }
    .local(file, ...)
}

Signatures:
        file
target  "connection"
defined "connection"
</pre>
<p>Note that if <tt>showMethods</tt> displays &#8220;inherited from&#8221; below a particular signature, then this isn&#8217;t a full method definition, but is just inherited from the definition for another signature (and you should call <tt>getMethod</tt> on that signature instead).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=129&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2011/01/04/how-to-see-the-code-for-s4-methods-in-r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to install the Vienna RNA Package on Ubuntu</title>
		<link>http://missingreadme.wordpress.com/2010/11/08/how-to-install-the-vienna-rna-package/</link>
		<comments>http://missingreadme.wordpress.com/2010/11/08/how-to-install-the-vienna-rna-package/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 01:12:32 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[bioinformatics]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=123</guid>
		<description><![CDATA[I&#8217;ve been trying to install the Vienna RNA Package from source on Ubuntu Lucid Linx (10.04), but every time I tried make it would fail with the following errors: rnafuncs.cpp:341: error: ‘sprintf’ was not declared in this scope rnafuncs.cpp:361: error: ‘sprintf’ was not declared in this scope rnafuncs.cpp:582: error: ‘sprintf’ was not declared in this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=123&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to install the <a href="http://www.tbi.univie.ac.at/RNA/">Vienna RNA Package</a> from source on <a href="http://releases.ubuntu.com/lucid/">Ubuntu Lucid Linx (10.04)</a>, but every time I tried <tt>make</tt> it would fail with the following errors:</p>
<p><pre>
rnafuncs.cpp:341: error: ‘sprintf’ was not declared in this scope
rnafuncs.cpp:361: error: ‘sprintf’ was not declared in this scope
</pre>
</p>
<p><pre>
rnafuncs.cpp:582: error: ‘sprintf’ was not declared in this scope
rnafuncs.cpp:588: error: ‘sprintf’ was not declared in this scope
</pre>
</p>
<p>I thought that looked a bit odd (how could a standard function like <tt>sprintf</tt> not be declared?) but after a little googling I found this page (in Japanese &#8211; I suggest using Google translate if you can&#8217;t read Japanese), where the author points out that the source file in question does not include <tt>stdio.h</tt> which defines <tt>sprintf</tt>. After editing <tt>rnafuncs.cpp</tt> to include including <tt>stdio.h</tt> everything compiled without any errors (although there were still a few minor warnings).</p>
<h3>Solution</h3>
<p>Inside the Vienna RNA Package source folder (for me this is <tt>ViennaRNA-1.8.4</tt>), open <tt>RNAforester/src/rnafuncs.cpp</tt> and add <tt>#include &lt;stdio.h&gt;</tt> on line 9, so that it looks like this:</p>
<p><pre>
#include
#include
#include
#include
#include
#include
#include
#include 

#ifndef WIN32
#include "config.h"
#endif
</pre>
</p>
<p>After saving, it should compile and install without errors.</p>
<h3>Note</h3>
<p>If you want to use <a href="http://bibiserv.techfak.uni-bielefeld.de/rnaforester/">RNAForester</a> you will also need to install the g2 graphics package (as explained in <tt>INSTALL</tt>). In Ubuntu this package is called <tt>libg20</tt>, and you can install it using Synaptic.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=123&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/11/08/how-to-install-the-vienna-rna-package/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to update submodules in git</title>
		<link>http://missingreadme.wordpress.com/2010/11/06/how-to-update-submodules-in-git/</link>
		<comments>http://missingreadme.wordpress.com/2010/11/06/how-to-update-submodules-in-git/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 05:49:19 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=118</guid>
		<description><![CDATA[Git is a great tool, but very confusing for anyone who comes from a SVN or CVS background. Most of what it does is straightforward (if you learn it from the right place &#8211; I strongly recommend Pro Git for anyone who wants to learn git), but using submodules is a bit confusing. I&#8217;ve found [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=118&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://git-scm.com/">Git</a> is a great tool, but very confusing for anyone who comes from a SVN or CVS background. Most of what it does is straightforward (if you learn it from the right place &#8211; I strongly recommend <a href="http://progit.org/book/">Pro Git</a> for anyone who wants to learn git), but using submodules is a bit confusing. I&#8217;ve found that <a href="http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/">Chris Jean&#8217;s Blog</a> and the <a href="http://progit.org/book/ch6-6.html">chapter on submodules</a> in Pro Git both explain different parts of it well (I recommend reading them in that order), but it still takes a little effort to work out what you should do when you want to apply updates from a submodule&#8217;s own repository to the version that you have in your own project. Here is a summary of my understanding.</p>
<h3>Solution</h3>
<p>Submodules are always headless when they are comitted: you are only committing a tag, not the code that is in the submodule folder.</p>
<p>There are two scenarios for updating a submodule (in all of the following, I assume that you have already initialised and updated your submodule):</p>
<ul>
<li><strong>You want to update the submodule locally and push the update to the repository:</strong>
<ol>
<li>Change your submodule from a headless branch (the state that it will be in after running <tt>git submodule update</tt>) onto a working branch (eg. origin/master), using <tt>git checkout</tt></li>
<li>Update the submodule using <tt>git pull</tt> from inside the submodule&#8217;s directory</li>
<li>Change to the parent directory of the submodule and add the submodule directory to the staging area using <tt>git add</tt></li>
<li>Commit using <tt>git commit</tt></li>
<li>If you&#8217;re using a remote repository, now use <tt>git push</tt></li>
</ol>
<p>Note that this will commit the submodule tag that was pushed most recently, not the code that&#8217;s actually in the submodule directory, therefore any code in the submodule that was not pushed will be lost (as explained in <a href="http://progit.org/book/ch6-6.html">Pro Git</a>)</li>
<li><strong>Someone else updates the submodule and you want to pull the change from the repository:</strong>
<ol>
<li>Use <tt>git submodule update</tt> to pull the changes from the repository. This will overwrite your local version of the submodule with a headless branch (if you&#8217;d like to now edit it, use the procedure above).</li>
</ol>
</li>
</ul>
</li>
</ul>
<p>It&#8217;s also worth remembering that the submodule directory acts like a git repo in it&#8217;s own right, so changes made and commands run inside that directory will affect the submodule whereas changes and commands used outside will affect the parent project instead.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=118&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/11/06/how-to-update-submodules-in-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to write a correct implementation of merge sort</title>
		<link>http://missingreadme.wordpress.com/2010/10/14/how-to-write-a-correct-implementation-of-merge-sort/</link>
		<comments>http://missingreadme.wordpress.com/2010/10/14/how-to-write-a-correct-implementation-of-merge-sort/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 11:55:22 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[algorithms]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=111</guid>
		<description><![CDATA[Josh Bloch always has very interesting things to say. I came across this blog post by him accidentally, but it&#8217;s a very interesting point: most implementations of merge sort break down for really large arrays (unbelievably large arrays if you&#8217;re using a 64bit processor). The problem comes when the algorithm tries to calculate the index [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=111&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Joshua_Bloch">Josh Bloch</a> always has very interesting things to say. I came across this blog post by him accidentally, but it&#8217;s a very interesting point: most implementations of merge sort break down for really large arrays (unbelievably large arrays if you&#8217;re using a 64bit processor). The problem comes when the algorithm tries to calculate the index of the pivot: most implementations will do this:</p>
<pre>
mid = (low + high) / 2
</pre>
<p>but this will overflow if both low and high are very large. You can read the full article <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html">here</a>.</p>
<p>I guess the take-home point here is to bear overflows in mind when performing integer arithmetic, especially in core areas of code where your data structures could potentially grow to an enormous size in the future (after all, &#8220;640K ought to be enough for anybody&#8221;).</p>
<h3>Solution</h3>
<p>Rather than calculating the average of the low and high bounds, calculate the difference between the two and use that to find the pivot:</p>
<pre>
mid = low + ((high - low) / 2)
</pre>
<p>(This is the most language neutral way of calculating it, although Josh does offer more efficient versions for languages with bit-shifting)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=111&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/10/14/how-to-write-a-correct-implementation-of-merge-sort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to change your Microsoft Office for Mac license key</title>
		<link>http://missingreadme.wordpress.com/2010/10/08/how-to-change-your-microsoft-office-for-mac-license-key/</link>
		<comments>http://missingreadme.wordpress.com/2010/10/08/how-to-change-your-microsoft-office-for-mac-license-key/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 01:14:29 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[microsoft office]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=101</guid>
		<description><![CDATA[This one&#8217;s easy. Microsoft office for mac checks whether the license key you&#8217;re using is already being used by someone else (I think it only checks on your local network, but perhaps it uses the internet? I&#8217;m not sure). But sometimes you need to move people between computers and you can end up with more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=101&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This one&#8217;s easy. Microsoft office for mac checks whether the license key you&#8217;re using is already being used by someone else (I think it only checks on your local network, but perhaps it uses the internet? I&#8217;m not sure). But sometimes you need to move people between computers and you can end up with more than one person using the same license key. To fix this you need to delete the old license key (on one of the computers) and enter a new one. Microsoft doesn&#8217;t provide an easy way to do this but I found a solution online.</p>
<p>Thanks go to <a href="http://tech.chitgoks.com/2008/06/13/change-product-key-of-mac-office-2008/">Tech Tips Tricks</a> for showing me how to do this (note that <a href="http://tech.chitgoks.com/2008/06/13/change-product-key-of-mac-office-2008/">Tech Tip Tricks</a> suggests also deleting a user preference file, but this file doesn&#8217;t exist on any system that I&#8217;ve tried this on)</p>
<h3>Solution</h3>
<p>Delete this file:</p>
<pre>
/Applications/Microsoft Office 2008/Office/OfficePID.plist
</pre>
<p>then when you next start office it will ask for your new license key.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=101&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/10/08/how-to-change-your-microsoft-office-for-mac-license-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to add a Ruby on Rails association from inside a module/mixin</title>
		<link>http://missingreadme.wordpress.com/2010/09/23/how-to-add-a-ruby-on-rails-association-from-inside-a-modulemixin/</link>
		<comments>http://missingreadme.wordpress.com/2010/09/23/how-to-add-a-ruby-on-rails-association-from-inside-a-modulemixin/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 03:34:30 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=95</guid>
		<description><![CDATA[Sometimes you have several models that don&#8217;t just similar functionality but similarly named associations, and it&#8217;d be good practice to define those associations in a mixin. Doing so however is a bit of a black art. I found out how to do this from www.teachmetocode.com (and the code below includes the hint from Stefan Kanev&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=95&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you have several models that don&#8217;t just similar functionality but similarly named associations, and it&#8217;d be good practice to define those associations in a mixin. Doing so however is a bit of a black art. I found out how to do this from <a href="http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/">www.teachmetocode.com</a> (and the code below includes the hint from Stefan Kanev&#8217;s comment).</p>
<h3>Solution</h3>
<p>Write a module similar to the following, the include it from your models in order to gain access to the association.</p>
<pre>
module AssociationModule
  def self.included(base)
    base.has_many :things, :class_name =&gt; "#{base.name}Thing"
  end
end
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=95&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/09/23/how-to-add-a-ruby-on-rails-association-from-inside-a-modulemixin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>Recursive blocks/procs/lambdas in Ruby</title>
		<link>http://missingreadme.wordpress.com/2010/09/22/recursive-blocksprocslambdas-in-ruby/</link>
		<comments>http://missingreadme.wordpress.com/2010/09/22/recursive-blocksprocslambdas-in-ruby/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 00:59:43 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=92</guid>
		<description><![CDATA[I need to start doing more &#8220;quick-fire&#8221; posts of cool things I find, rather than saving up big-ticket items that never get posted. Anyway&#8230; I just had an interesting coding problem where I needed to have a quick recursive function in Ruby on Rails and I didn&#8217;t want to move it into it&#8217;s own method. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=92&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I need to start doing more &#8220;quick-fire&#8221; posts of cool things I find, rather than saving up big-ticket items that never get posted. Anyway&#8230;</p>
<p>I just had an interesting coding problem where I needed to have a quick recursive function in Ruby on Rails and I didn&#8217;t want to move it into it&#8217;s own method. A lambda or proc would have been perfect but it needed to be recursive (and &#8220;how can you self-reference a lambda&#8221; I thought?). Well it turns out it&#8217;s not that hard. It seems that variables defined outside of a lambda are still in-scope inside of the lambda.</p>
<p>I learned how to do this from <a href="http://blog.hasmanythrough.com/2008/6/20/recursive-lambda">Josh Susser</a>, who has a Ruby on Rails specific example.</p>
<h3>Solution</h3>
<p>Here is a simple example to calculate factorials using a lambda:</p>
<pre>
factorial = lambda do |n|
  n &lt;= 1 ? 1 : (n * factorial.call(n - 1))
end
</pre>
<p>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=92&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/09/22/recursive-blocksprocslambdas-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to set up AFP filesharing on Ubuntu</title>
		<link>http://missingreadme.wordpress.com/2010/05/08/how-to-set-up-afp-filesharing-on-ubuntu/</link>
		<comments>http://missingreadme.wordpress.com/2010/05/08/how-to-set-up-afp-filesharing-on-ubuntu/#comments</comments>
		<pubDate>Sat, 08 May 2010 01:19:33 +0000</pubDate>
		<dc:creator>Iain Beeston</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[afp]]></category>
		<category><![CDATA[avahi]]></category>
		<category><![CDATA[bonjour]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[netatalk]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://missingreadme.wordpress.com/?p=55</guid>
		<description><![CDATA[This how-to is a mashup of two different tutorials that I found on the web, but neither was up-to-date or did everything that I wanted. But thanks for to Kremalicious and damontimm for getting me started. After struggling with using Samba for filesharing on our mac-only network (the final straw was file permissions that just [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=55&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This how-to is a mashup of two different tutorials that I found on the web, but neither was up-to-date or did everything that I wanted. But thanks for to <a href="http://www.kremalicious.com/2008/06/ubuntu-as-mac-file-server-and-time-machine-volume/">Kremalicious</a> and <a href="http://blog.damontimm.com/how-to-install-netatalk-afp-on-ubuntu-with-encrypted-authentication/">damontimm</a> for getting me started.</p>
<p>After struggling with using <a href="http://en.wikipedia.org/wiki/Samba_(software)">Samba</a> for filesharing on our mac-only network (the final straw was file permissions that just wouldn&#8217;t work for everyone), I finally gave up and decided to try using <a href="http://en.wikipedia.org/wiki/Apple_Filing_Protocol">AFP</a> instead. I&#8217;d looked at it before, but it didn&#8217;t look easy to set up or production ready, but things have changed and I didn&#8217;t find it hard at all and it&#8217;s now working far better than Samba ever did.</p>
<p>There are two components to natural looking AFP:</p>
<ol>
<li><a href="http://en.wikipedia.org/wiki/Apple_Filing_Protocol">AFP</a> (obviously)</li>
<li><a href="http://en.wikipedia.org/wiki/Zeroconf">Zeroconf</a></li>
</ol>
<p>(Zeroconf is the unbranded name for <a href="http://en.wikipedia.org/wiki/Bonjour_(software)">Bonjour</a>, and is necessary to advertise your AFP volume over the network) In the case of Ubuntu these are provided by <a href="http://en.wikipedia.org/wiki/Netatalk">Netatalk</a> and <a href="http://en.wikipedia.org/wiki/Avahi_(software)">Avahi</a> respectively, and as neither come by default on Ubuntu we have to install and configure both (but it&#8217;s not as hard as it sounds).</p>
<h3>Solution</h3>
<h4>1. Netatalk</h4>
<p>Since Ubuntu 9.04 Netatalk has worked &#8220;out-of-the-box&#8221;, so all you need to do is install it (and tweak the settings slightly). Run the following command to install it:</p>
<pre>
sudo apt-get install netatalk
</pre>
</p>
<p>The next step is optional, but it should make your AFP server a little quicker. By default Netatalk turns on support for filesharing with pre-OS X Macs, but this is normally redundant. To turn it off, open <tt>/etc/default/netatalk</tt> and change the matching part of the file to:</p>
<pre>
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no
</pre>
</p>
<p>The final step is to tell Netatalk which directories it should share. By default it will only share users home directories, but to share any other folders (such as shared folders), open <tt>/etc/netatalk/AppleVolumes.default</tt> and add the following to the bottom (for each directory that you wish to share):</p>
<pre>
/your/path  VolumeName allow:@groupname options:usedots,upriv
</pre>
<p>There are a number of options that you can set here, for the full description see <a href="http://netatalk.sourceforge.net/2.0/htmldocs/AppleVolumes.default.5.html">this</a> page.</p>
<p>Now if you restart AFP:</p>
<pre>
sudo /etc/init.d/netatalk restart
</pre>
<p>it should be working, although you can only connect using the IP address of your Ubuntu machine. I&#8217;d recommend testing that it works at this point by opening Finder and selecting Go -&gt; Connect To Server, then entering &#8220;afp:://yourip/&#8221;, logging in with an Ubuntu user account and making sure that it works.</p>
<h4>2. Avahi</h4>
<p>To install Avahi (and mDNS which helps it imitate Bonjour), run the following command:</p>
<pre>
sudo apt-get install avahi-daemon libnss-mdns
</pre>
<p>Then open <tt>/etc/nsswitch.conf</tt> and add &#8220;mdns&#8221; to the end of the following line so that it looks like this:</p>
<pre>
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
</pre>
</p>
<p>Finally we need to configure Avahi to advertise the AFP service. To do this, create a new file at <tt>/etc/avahi/services/afpd.service</tt>, and enter the following into it:</p>
<pre>&lt;?xml version="1.0" standalone='no'?&gt;&lt;!--*-nxml-*--&gt;
&lt;!DOCTYPE service-group SYSTEM "avahi-service.dtd"&gt;
&lt;service-group&gt;
    &lt;name replace-wildcards="yes"&gt;%h&lt;/name&gt;
    &lt;service&gt;
        &lt;type&gt;_afpovertcp._tcp&lt;/type&gt;
        &lt;port&gt;548&lt;/port&gt;
    &lt;/service&gt;
    &lt;service&gt;
        &lt;type&gt;_device-info._tcp&lt;/type&gt;
        &lt;port&gt;0&lt;/port&gt;
        &lt;txt-record&gt;model=MacPro&lt;/txt-record&gt;
    &lt;/service&gt;
&lt;/service-group&gt;
</pre>
<p>The first service tag advertises AFP (which uses port 548 by default). The second service tag tells OS X what icon to use for your Ubuntu machine in finder, you can set this to: Macmini, iMac, MacPro, Xserve, MacBook, MacBookPro or MacBookAir as appropriate.</p>
<p>Now if you restart Avahi using this command:</p>
<pre>
sudo /etc/init.d/avahi-daemon restart
</pre>
<p>your AFP volume should appear on any Mac on the network.</p>
<h3>Note</h3>
<p>Netatalk 2 doesn&#8217;t handle symbolic links how you&#8217;d expect (at best the contents of a symlink might be inaccessible). This is a design feature, not a bug, and the Netatalk team recommend avoiding their use in shared volumes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/missingreadme.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/missingreadme.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/missingreadme.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/missingreadme.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/missingreadme.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/missingreadme.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/missingreadme.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/missingreadme.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=missingreadme.wordpress.com&amp;blog=10460322&amp;post=55&amp;subd=missingreadme&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://missingreadme.wordpress.com/2010/05/08/how-to-set-up-afp-filesharing-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4ec7cb42339aacafc17395000e2c97d4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tensaiji</media:title>
		</media:content>
	</item>
	</channel>
</rss>
