<?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>unsignedint &#187; Development</title>
	<atom:link href="http://unsignedint.net/blog/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://unsignedint.net/blog</link>
	<description>adding noise to the signal</description>
	<lastBuildDate>Sat, 10 Jul 2010 10:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>O CDN da Google, jQuery e algumas implicações</title>
		<link>http://unsignedint.net/blog/2010/04/03/google-cdn-jquery/</link>
		<comments>http://unsignedint.net/blog/2010/04/03/google-cdn-jquery/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 20:25:13 +0000</pubDate>
		<dc:creator>lmmendes</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[google cdn]]></category>

		<guid isPermaLink="false">http://www.unsignedint.net/blog/?p=370</guid>
		<description><![CDATA[Ultimamente tenho-me sentido tentado em usar a Content Delivery Network (CDN) da Google para servir algumas das bibliotecas javascript que utilizo, nomeadamente o jQuery e JQuery UI. As vantagens de utilizar o CDN da Google são óbvias, os servidores deles são rápidos bem rápidos e outra vantagem prende-se com o facto se houver muita gente [...]]]></description>
			<content:encoded><![CDATA[<p>Ultimamente tenho-me sentido tentado em usar a <a href="http://en.wikipedia.org/wiki/Content_delivery_network" target="_blank">Content Delivery Network</a> (CDN) da Google para servir algumas das bibliotecas javascript que utilizo, nomeadamente o <a href="http://jquery.com/" target="_blank">jQuery</a> e <a href="http://jqueryui.com/" target="_blank">JQuery UI</a>.</p>
<p>As vantagens de utilizar o CDN da Google são óbvias, os servidores deles são rápidos bem rápidos e outra vantagem prende-se com o facto se houver muita gente a utilizar o CDN deles provavelmente quando um utilizador chegar ao meu site o jQuery servido pelo Google já está em cache e ai o tempo de download é zero (ou muito perto disso pelo menos) entre outras vantagens que no final de contas resultam num carregamento mais rápido da pagina e uma redução na carga sobre a nossa maquina.<br />
<span id="more-370"></span><br />
Contudo não há bela sem senão e neste caso o senão é que estamos a confiar a terceiros para nos servirem um conteúdo directamente no nosso site (e no caso de javascript pode ser algo bastante perigoso), outro senão é o que acontece ao nosso site se o Google tiver problemas de rede e os ficheiros ficarem de alguma forma indisponíveis?</p>
<p>Pois bem, quanto ao problema de segurança que representa confiar na Google para servir  os nossos ficheiros isto é algo com que teremos que viver se quisermos utilizar qualquer CDN e para mais a maioria de nós já confia na Google para servir o javascript do Google Analytics.</p>
<p>Quanto para o caso da rede da Google falhar no que diz respeito ao jQuery a solução é bastante simples.<br />
Se tivermos em conta que um browser executa de ordem sequencial o carregamento de todo o javascript  e sabendo que o jQuery depois de carregado disponibiliza um objecto (variável) com o nome de jQuery  facilmente podemos construir algo que tenta carregar o jQuery a partir do CDN da Google e se depois o objecto jQuery não estiver disponível carrega então o jQuery a partir do repositorio do nosso site.</p>
<pre name="code" class="javascript">
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
</pre>
<pre name="code" class="javascript">
<script type="text/javascript">
if(  typeof jQuery === 'undefined' ){
  document.write('<scr'+'ipt src="/static/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>');
}
</script>
</pre>
<p>Como podemos ver pelo código em cima é bastante simples aproveitar-nos das vantagem da utilização do CDN da Google e também conseguimos nos proteger contra qualquer problema de disponibilidade acabando por servir a nossa versão local em caso de algum problema.</p>
<div class="shr-publisher-370"></div>]]></content:encoded>
			<wfw:commentRss>http://unsignedint.net/blog/2010/04/03/google-cdn-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Como obter o ID de um post dentro e fora do Loop do WordPress</title>
		<link>http://unsignedint.net/blog/2010/01/16/obter-id-de-um-post-no-wordpress/</link>
		<comments>http://unsignedint.net/blog/2010/01/16/obter-id-de-um-post-no-wordpress/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 11:46:29 +0000</pubDate>
		<dc:creator>lmmendes</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[post_id]]></category>

		<guid isPermaLink="false">http://www.unsignedint.net/blog/?p=342</guid>
		<description><![CDATA[Ultimamente tenho andado a fazer algumas modificações ao meu blog e surgiu-me a necessidade de obter o ID de um post fora do loop (The Loop) do WordPress: &#60;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&#62; Dentro do loop para obter o ID basta fazer o seguinte: $post->ID Já fora [...]]]></description>
			<content:encoded><![CDATA[<p>Ultimamente tenho andado a fazer algumas modificações ao meu blog e surgiu-me a necessidade de obter o ID de um post fora do <a href="http://codex.wordpress.org/The_Loop">loop (The Loop)</a> do WordPress:</p>
<pre name="code" class="php">
&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;
</pre>
<p>Dentro do <em>loop </em>para obter o ID basta fazer o seguinte:</p>
<pre name="code" class="php">
$post->ID
</pre>
<p>Já fora do <em>loop</em> para termos acesso ao ID do post vamos ter que aceder á variável global <em>$wp_query</em>, ou seja, para obtermos acesso ao ID do post:</p>
<pre name="code" class="php">
global $wp_query;
$wp_query->post->ID
</pre>
<p>É tão simples como isso, para saberem mais informação sobre o <em>$wp_query</em> consultem o <a href="http://codex.wordpress.org/Function_Reference/WP_Query">Codex aqui.</a></p>
<div class="shr-publisher-342"></div>]]></content:encoded>
			<wfw:commentRss>http://unsignedint.net/blog/2010/01/16/obter-id-de-um-post-no-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove WordPress iNove theme sidebar using custom fields</title>
		<link>http://unsignedint.net/blog/2010/01/16/hide-inove-wordpress-theme-sidebar-using-custom-fields/</link>
		<comments>http://unsignedint.net/blog/2010/01/16/hide-inove-wordpress-theme-sidebar-using-custom-fields/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 01:35:37 +0000</pubDate>
		<dc:creator>lmmendes</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[inove wordpress nosidebar]]></category>

		<guid isPermaLink="false">http://www.unsignedint.net/blog/?p=295</guid>
		<description><![CDATA[I&#8217;m using WordPress iNove theme v.1.4.6 and i needed a way to hide the sidebar for a specific post so i dove in the iNove theme code and figured out how to do this with the minimum changes to the original theme code. First open the iNove theme &#8216;header.php&#8217; file using your favorite editor, usually [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using <a href="http://wordpress.org/extend/themes/inove">WordPress iNove theme</a> v.1.4.6 and i needed a way to hide the sidebar for a specific post so i dove in the iNove theme code and figured out how to do this with the minimum changes to the original theme code.</p>
<p>First open the iNove theme &#8216;header.php&#8217; file using your favorite editor, usually found at <em>&lt;wp install folder&gt;/wp-content/themes/inove/header.php</em>.</p>
<p>Now look for this piece of code (starting from the top of the file):</p>
<pre name="code" class="php">
... some code ...
			$feed = 'http://' . $options['feed_url'];
		}
	} else {
		$feed = get_bloginfo('rss2_url');
	}
?&gt;
</pre>
<p><span id="more-295"></span><br />
Now append at the end of that code the following snippet:</p>
<pre name="code" class="php">
&lt;?php
    global $wp_query;
    if( get_post_meta( $wp_query->post->ID, 'nosidebar', 'true') ){
        $inove_nosidebar = true;
    }
?&gt;
</pre>
<p>You should get some thing like this:</p>
<pre name="code" class="php">
... some code ...
			$feed = 'http://' . $options['feed_url'];
		}
	} else {
		$feed = get_bloginfo('rss2_url');
	}
?&gt;

&lt;?php
    global $wp_query;
    if( get_post_meta( $wp_query->post->ID, '', 'true') ){
        $inove_nosidebar = true;
    }
?&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
</pre>
<p>Now when you need to disable the sidebar in a post you simply add  a new &#8216;Custom Field&#8217; named &#8216;nosidebar&#8217; and set it&#8217;s value to &#8216;true&#8217; like you see in the figure.</p>
<p><a href="http://www.unsignedint.net/blog/wp-content/uploads/2010/01/wp_nosidebar_custom_fields.png"><img src="http://www.unsignedint.net/blog/wp-content/uploads/2010/01/wp_nosidebar_custom_fields.png" alt="Wordpress setting &#039;nosidebar&#039; custom field" title="Wordpress &#039;nosidebar&#039; Custom Fields" width="582" height="233" class="alignnone size-full wp-image-320" /></a></p>
<p>Et voilà, all done! </p>
<div class="shr-publisher-295"></div>]]></content:encoded>
			<wfw:commentRss>http://unsignedint.net/blog/2010/01/16/hide-inove-wordpress-theme-sidebar-using-custom-fields/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Installing nginx and rails passenger on Mac OS X Snow Leopard</title>
		<link>http://unsignedint.net/blog/2009/10/17/installing-nginx-and-rails-passenger-on-mac-os-x-snow-leopard/</link>
		<comments>http://unsignedint.net/blog/2009/10/17/installing-nginx-and-rails-passenger-on-mac-os-x-snow-leopard/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 11:07:50 +0000</pubDate>
		<dc:creator>lmmendes</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.unsignedint.net/blog/?p=170</guid>
		<description><![CDATA[I&#8217;m new to Mac OS X, nginx and rails so after much goggling i finally got everything to work so i resolved to compile the list of instructions that i followed. First we need to download, compile and install PRE (Perl Compatible Regular Expressions) it&#8217;s required for nginx. You can find the most recent version [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m new to Mac OS X, nginx and rails so after much goggling i finally got everything to work so i resolved to compile the list of instructions that i followed.</p>
<p>First we need to download, compile and install PRE (Perl Compatible Regular Expressions) it&#8217;s required for nginx. You can find the most recent version here http://www.pcre.org/ , at time of writing this post the most recent version is 7.9</p>
<p>Compiling and installing PRE</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>src
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>src
curl <span style="color: #660033;">-O</span> <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>ftp.csx.cam.ac.uk<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>programming<span style="color: #000000; font-weight: bold;">/</span>pcre<span style="color: #000000; font-weight: bold;">/</span>pcre-<span style="color: #000000;">7.9</span>.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> pcre-<span style="color: #000000;">7.9</span>.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> pre-<span style="color: #000000;">7.9</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></td></tr></table></div>

<p>Installing Phusion Passenger via gem</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger</pre></td></tr></table></div>

<p>Now that you have Phusion Passenger installed you can install and configure nginx and passenger using a bundled script from passenger called &#8220;passenger-install-nginx-module&#8221; but that is no fun and usually don&#8217;t install the lasted stable version of nginx, so you can run the script and follow it&#8217;s instructions (that include auto-downloading and installing of nginx) or do it my way&#8230; the hard way.</p>
<p>So now we need to find where &#8220;gem&#8221; installed the nginx module so we can refer to it&#8217;s during the nginx configuration, so to get the module path you just need to run this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">passenger-config <span style="color: #660033;">--root</span></pre></td></tr></table></div>

<p>In my case the command output is</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/&lt;</span>usename<span style="color: #000000; font-weight: bold;">&gt;/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.5</pre></td></tr></table></div>

<p>You need to write down this output, you will need it in the next step.</p>
<p>Now it&#8217;s time do download and install nginx we will be installing version 0.7.62 (stable).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>src
curl <span style="color: #660033;">-O</span> http:<span style="color: #000000; font-weight: bold;">//</span>sysoev.ru<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx-0.7.62.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> nginx-0.7.62.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> nginx-0.7.62
.<span style="color: #000000; font-weight: bold;">/</span>configure \
<span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span> \
<span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf \
<span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access_log \
<span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error_log \
<span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid \
<span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>client \
<span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy \
<span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi \
<span style="color: #660033;">--with-md5-asm</span> <span style="color: #660033;">--with-md5</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include \
<span style="color: #660033;">--with-sha1-asm</span> \
<span style="color: #660033;">--with-sha1</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
<span style="color: #660033;">--add-module</span>=<span style="color: #ff0000;">'/Users/&lt;username&gt;/.gem/ruby/1.8/gems/passenger-2.2.5/ext/nginx'</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></td></tr></table></div>

<p>Has you can see in line <strong>20</strong> you need to add the previous output that i told you to write down.</p>
<p>The nginx install path&#8217;s, bin, etc&#8230; :</p>
<p>bin: /usr/local/sbin/nginx<br />
etc: /etc/nginx/<br />
pid: /var/run/nginx.pid<br />
document root: /usr/local/html/<br />
error log: /var/log/nginx/error_log</p>
<p>Now let&#8217;s create a demo rails application to show things working</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">rails ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>blog</pre></td></tr></table></div>

<p>Edit /etc/nginx/nginx.conf (you can use your favorit text editor, i will be using vi)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf</pre></td></tr></table></div>

<p>Find the &#8220;http&#8221; section and add this lines</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">passenger_root <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/&lt;</span>username<span style="color: #000000; font-weight: bold;">&gt;/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.5;
passenger_ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby;</pre></td></tr></table></div>

<p>You should get something like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    include       mime.types;
    default_type  application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;
&nbsp;
    passenger_root <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/&lt;</span>username<span style="color: #000000; font-weight: bold;">&gt;/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.5;
    passenger_ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby;
. . . .</pre></td></tr></table></div>

<p>Now adding the virtual host to nginx.conf to run ~/Sites/blog app ( /Users/<username>/Sites/blog )</p>
<p>Add a new server configuration (vhost) inside the http section of the nginx.conf file like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">  server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
          passenger_enabled on;
          listen <span style="color: #000000;">80</span>;
          server_name blog;
          root <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/&lt;</span>username<span style="color: #000000; font-weight: bold;">&gt;/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>blog<span style="color: #000000; font-weight: bold;">/</span>public;
          rails_env development;
  <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>Now save the file and let&#8217;s se if it&#8217;s all working.</p>
<p>Start the nginx like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx</pre></td></tr></table></div>

<p>Let&#8217;s edit the /etc/host file to add the new vhost name ( blog )</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts</pre></td></tr></table></div>

<p>add this to the bottom of the file, save and exit</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">127.0.0.1       blog</pre></td></tr></table></div>

<p>Now point your browser to <strong>http://blog</strong> and you should the the standard rails app page if you experince any problem starting nginx use this command to see nginx error log</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error_log</pre></td></tr></table></div>

<p>All done, i hope it helps you.</p>
<div class="shr-publisher-170"></div>]]></content:encoded>
			<wfw:commentRss>http://unsignedint.net/blog/2009/10/17/installing-nginx-and-rails-passenger-on-mac-os-x-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Error: #1005 &#8211; Can&#039;t create table &#039;&#8230;.#sql-e7c_89.frm&#039; (errno: 150)</title>
		<link>http://unsignedint.net/blog/2009/08/01/mysql-error-1005-cant-create-table-sql-e7c_89-frm-errno-150/</link>
		<comments>http://unsignedint.net/blog/2009/08/01/mysql-error-1005-cant-create-table-sql-e7c_89-frm-errno-150/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 23:28:04 +0000</pubDate>
		<dc:creator>unsignedint</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[innodb]]></category>

		<guid isPermaLink="false">http://unsignedint.net/blog/?p=40</guid>
		<description><![CDATA[Se estiverem a tentar criar uma relação entre duas tabelas usando o MySQL e obtiverem o seguinte erro: #1005 - Can't create table '.\twitta\#sql-e7c_89.frm' (errno: 150) Experimentem activar o modo de debug do motor de innoDB de forma a obter mais informações sobre o erro e a poderem-no perceber. Para tal digitem na vossa consola: [...]]]></description>
			<content:encoded><![CDATA[<p>Se estiverem a tentar criar uma relação entre duas tabelas usando o MySQL e obtiverem o seguinte erro:</p>
<pre name="code" class="sql">
#1005 - Can't create table '.\twitta\#sql-e7c_89.frm' (errno: 150)
</pre>
<p>
Experimentem activar o modo de debug do motor de <strong>innoDB</strong> de forma a obter mais informações sobre o erro e a poderem-no perceber.<br />
<span id="more-40"></span><br />
Para tal digitem na vossa consola:</p>
<pre name="code" class="sql">
mysql> SHOW ENGINE INNODB STATUS;
</pre>
<p>E agora fazendo scroll para para cima sobre o output apresentado podem ver uma mensagem de erro mais detalhada. no meu caso foi:<br />
</p>
<pre name="code" class="sql">
------------------------
LATEST FOREIGN KEY ERROR
------------------------
090801 23:41:40 Error in foreign key constraint of table twitta/#sql-e7c_8a:
 FOREIGN KEY ( `user_id` ) REFERENCES `users` ( `id` ) ON DELETE CASCADE:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
</pre>
<p>Depois de consultar a documentação que o modo de debug sugere, rapidamente me apercebi do meu erro. A tabela onde estava criar a chave estrangeira o campo referenciado não estava indexado. Como se pode ler na documentação:</p>
<pre>
InnoDB requires indexes on foreign keys and referenced keys so that foreign key
checks can be fast and not require a table scan. In the referencing table,
there must be an index where the foreign key columns are listed as the first
columns in the same order. Such an index is created on the referencing table
automatically if it does not exist. (This is in contrast to some older versions,
in which indexes had to be created explicitly or the creation of foreign key
constraints would fail.) index_name, if given, is used as described previously
</pre>
<p>Espero que isto vós ajude.</p>
<div class="shr-publisher-40"></div>]]></content:encoded>
			<wfw:commentRss>http://unsignedint.net/blog/2009/08/01/mysql-error-1005-cant-create-table-sql-e7c_89-frm-errno-150/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HttpFox &#8211; HTTP analyzer addon for Firefox</title>
		<link>http://unsignedint.net/blog/2009/05/12/httpfox/</link>
		<comments>http://unsignedint.net/blog/2009/05/12/httpfox/#comments</comments>
		<pubDate>Tue, 12 May 2009 21:53:37 +0000</pubDate>
		<dc:creator>unsignedint</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[addons]]></category>

		<guid isPermaLink="false">http://unsignedint.net/blog/?p=5</guid>
		<description><![CDATA[HttpFox monitors and analyzes all incoming and outgoing HTTP traffic between the browser and the web servers. It aims to bring the functionality known from tools like HttpWatch or IEInspector to the Firefox browser. Information available per request includes: - Request and response headers - Sent and received cookies - Querystring parameters - POST parameters [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://unsignedint.net/blog/2009/05/12/httpfox/httpfox/" rel="attachment wp-att-9"><img src="http://unsignedint.net/blog/wp-content/uploads/2009/05/httpfox-150x150.png" alt="httpfox" title="httpfox" width="150" height="150" class="alignleft size-thumbnail wp-image-9" /></a><br />
HttpFox monitors and analyzes all incoming and outgoing HTTP traffic between the browser and the web servers.</p>
<p>It aims to bring the functionality known from tools like HttpWatch or IEInspector to the Firefox browser.</p>
<p>Information available per request includes:<br />
- Request and response headers<br />
- Sent and received cookies<br />
- Querystring parameters<br />
- POST parameters<br />
- Response body</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/6647">HttpFox</a></p>
<div class="shr-publisher-5"></div>]]></content:encoded>
			<wfw:commentRss>http://unsignedint.net/blog/2009/05/12/httpfox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

