<?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>Ruby, Rails, OSX and Linux fun</title>
	<atom:link href="http://www.frederico-araujo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederico-araujo.com</link>
	<description>Ruby, Rails, OSX and linux sysadmin</description>
	<lastBuildDate>Sat, 07 Nov 2009 13:55:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Really checking the content-type/mime_type of a file in OSX and Linux</title>
		<link>http://www.frederico-araujo.com/2009/06/14/really-finding-the-content-type-of-a-file-in-osx-and-linux/</link>
		<comments>http://www.frederico-araujo.com/2009/06/14/really-finding-the-content-type-of-a-file-in-osx-and-linux/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 18:55:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[osx]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[content_type]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mime_type]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=95</guid>
		<description><![CDATA[I have came across many projects where checking file uploads and content-type (mime-type) is poorly implemented or heavy in resource.
Methods I have seen so far:
1. Checking content-type from file name: this inefficient, a user can just rename a file and you are fooled, or the file can have a different file format and you will [...]]]></description>
			<content:encoded><![CDATA[<p>I have came across many projects where checking file uploads and content-type (mime-type) is poorly implemented or heavy in resource.</p>
<p>Methods I have seen so far:</p>
<p>1. Checking content-type from file name: this inefficient, a user can just rename a file and you are fooled, or the file can have a different file format and you will not get the expected result.</p>
<p>2. Using Rmagick to check if the file is an image. This is so slow and uses so much Ram. You can try to initialize an rmagick object from an image file, then rescue when the file is not an image.</p>
<p>3. Using mini_magick to check if a file. This method is faster than rmagick. Implemen ted same way as rmagick.</p>
<p>A Better method for OSX and Linux,  is to use the command line tool &#8220;file&#8221; included in most UNIX operating systems.</p>
<p>It is very fast and very accurate.</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
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">file = <span style="color:#996600;">&quot;/path/to/file.ext&quot;</span>
<span style="color:#9966CC; font-weight:bold;">if</span> RUBY_PLATFORM.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>darwin<span style="color:#006600; font-weight:bold;">|</span>linux<span style="color:#006600; font-weight:bold;">|</span>unix<span style="color:#006600; font-weight:bold;">|</span>solaris<span style="color:#006600; font-weight:bold;">|</span>bsd<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
 content_type = <span style="color:#996600;">`file --raw --brief &quot;#{file}&quot;`</span>.<span style="color:#CC0066; font-weight:bold;">chomp</span>
 <span style="color:#9966CC; font-weight:bold;">case</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> content_type.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>image<span style="color:#006600; font-weight:bold;">|</span>png<span style="color:#006600; font-weight:bold;">|</span>jpg<span style="color:#006600; font-weight:bold;">|</span>jpeg<span style="color:#006600; font-weight:bold;">|</span>gif<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   real_type = <span style="color:#996600;">&quot;image&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> content_type.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>pdf<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   real_type = <span style="color:#996600;">&quot;pdf&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> content_type.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Microsoft Word|Microsoft Office Document&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   real_type = <span style="color:#996600;">&quot;doc&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#008000; font-style:italic;"># This can go on and on</span>
   real_type = <span style="color:#996600;">&quot;Unknown&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Some examples of content types:</p>
<p>.doc =  Microsoft Word document data</p>
<p>.doc = Microsoft Office Document</p>
<p>.pdf = PDF document, version 1.4</p>
<p>.pdf = PDF document, version 1.3</p>
<p>.psd = Adobe Photoshop Image</p>
<p>.png  = PNG image data, 3508 x 4961, 8-bit/color RGBA, non-interlaced</p>
<p>.gif = GIF image data, version 89a, 195 x 109</p>
<p>.jpg = JPEG image data, EXIF standard</p>
<p>etc&#8230;</p>
<p>I hope this can be useful to someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2009/06/14/really-finding-the-content-type-of-a-file-in-osx-and-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Easy installing Nginx + mod_rails passenger OSX</title>
		<link>http://www.frederico-araujo.com/2009/06/14/easy-installing-nginx-mod_rails-passenger-osx/</link>
		<comments>http://www.frederico-araujo.com/2009/06/14/easy-installing-nginx-mod_rails-passenger-osx/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 18:39:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[passenger]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=92</guid>
		<description><![CDATA[Requirements:
1. XCODE  you can download xcode from http://developer.apple.com/tools/xcode/index.html
2. OSX 10.4, 10.5 or 10.6
Procedures:
1. Install Passenger
$ sudo gem install passenger
now check where is passenger installed:

$ passenger-config --root

in my case is: /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.5
2. Install nginx
If you have nginx from macports, deactivate it in case of conflicts.
You can activate anytime later
$ sudo port deactivate nginx
$ wget http://sysoev.ru/nginx/nginx-0.7.59.tar.gz
$ wget [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Requirements</strong>:</p>
<p>1. XCODE  you can download xcode from <a href="http://developer.apple.com/tools/xcode/index.html">http://developer.apple.com/tools/xcode/index.html</a></p>
<p>2. OSX 10.4, 10.5 or 10.6</p>
<p><strong>Procedures</strong>:</p>
<p><strong>1. Install Passenger</strong></p>
<p>$ sudo gem install passenger</p>
<p>now check where is passenger installed:</p>
<pre>
$ passenger-config --root
</pre>
<p>in my case is: /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.5</p>
<p><strong>2. Install nginx</strong></p>
<p>If you have nginx from macports, deactivate it in case of conflicts.</p>
<p>You can activate anytime later</p>
<p>$ sudo port deactivate nginx</p>
<p><del datetime="2009-06-16T13:04:06+00:00">$ wget http://sysoev.ru/nginx/nginx-0.7.59.tar.gz</p>
<p>$ wget http://sysoev.ru/nginx/nginx-0.7.62.tar.gz</p>
<p>$ tar xpf nginx-0.7.62.tar.gz</p>
<p>$ cd nginx-0.7.62</p>
<p></del></p>
<p><del datetime="2009-09-23T22:31:19+00:00">
<p>I Recommend using nginx 0.6 series because I had a lot of  &#8220;502 Bad Gateway&#8221; with 0.7 series. </p>
<p>$ wget http://sysoev.ru/nginx/nginx-0.6.37.tar.gz</p>
<p>$ tar xpf nginx-0.6.37.tar.gz</p>
<p>$ cd nginx-0.6.37<br />
</del></p>
<pre>
$ sudo ./configure --add-module=/opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/nginx/ \
  --with-http_ssl_module --user=nobody --group=nobody --with-http_gzip_static_module \
  --with-poll_module --prefix=/opt/local --with-pcre
</pre>
<pre>
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1 library is not used
+ using system zlib library

nginx path prefix: "/opt/local"
nginx binary file: "/opt/local/sbin/nginx"
nginx configuration prefix: "/opt/local/conf"
nginx configuration file: "/opt/local/conf/nginx.conf"
nginx pid file: "/opt/local/logs/nginx.pid"
nginx error log file: "/opt/local/logs/error.log"
nginx http access log file: "/opt/local/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
</pre>
<p>$ sudo make</p>
<p>$ sudo make install</p>
<p>$ cd /opt/local/conf</p>
<p>$ sudo cp mime.types.default mime.types</p>
<p>$ sudo cp nginx.conf.default nginx.conf</p>
<p><strong>Edit nginx.conf</strong></p>
<p>$ mate nginx.conf</p>
<p>or</p>
<p>$ sudo vi nginx.conf</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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;">&nbsp;
<span style="color: #00007f;">user</span> nobody;
worker_processes  <span style="color: #ff0000;">2</span>;
&nbsp;
<span style="color: #adadad; font-style: italic;">#error_log  logs/error.log;</span>
<span style="color: #adadad; font-style: italic;">#error_log  logs/error.log  notice;</span>
error_log  logs/error.log  info;
&nbsp;
<span style="color: #adadad; font-style: italic;"># Pid</span>
pid  logs/nginx.pid;
&nbsp;
events {
worker_connections <span style="color: #ff0000;">1024</span>;
}
&nbsp;
http {
<span style="color: #00007f;">include</span>       mime.types;
default_type  application/octet-stream;
&nbsp;
sendfile        <span style="color: #0000ff;">on</span>;
<span style="color: #adadad; font-style: italic;">#tcp_nopush     on;</span>
&nbsp;
<span style="color: #adadad; font-style: italic;">#keepalive_timeout  0;</span>
keepalive_timeout  <span style="color: #ff0000;">65</span>;
&nbsp;
gzip  <span style="color: #0000ff;">on</span>;
<span style="color: #adadad; font-style: italic;"># if a precompiled gzip of the file exists, use it and force http proxies</span>
<span style="color: #adadad; font-style: italic;"># to use separate cache's based on User-Agent</span>
gzip_static <span style="color: #0000ff;">on</span>;
gzip_min_length <span style="color: #ff0000;">2000</span>;
gzip_buffers    <span style="color: #ff0000;">16</span> 8k;
gzip_types      text/plain text/html text/css image/x-icon application/xml application/xml+rss text/javascript;
gzip_disable    <span style="color: #7f007f;">&quot;MSIE [1-6] <span style="color: #000099; font-weight: bold;">\.</span>&quot;</span>;
gzip_vary         <span style="color: #0000ff;">on</span>;
gzip_comp_level   <span style="color: #ff0000;">2</span>;
&nbsp;
gzip_proxied any;
&nbsp;
server {
<span style="color: #00007f;">listen</span>       <span style="color: #ff0000;">80</span>;
server_name  localhost;
<span style="color: #00007f;">location</span> / {
root   /Users/fred/Sites ;
autoindex <span style="color: #0000ff;">on</span>;
index  index.html index.htm;
}
}
&nbsp;
passenger_root /opt/local/lib/ruby/gems/<span style="color: #ff0000;">1.8</span>/gems/passenger-2.2.2;
passenger_max_pool_size <span style="color: #ff0000;">8</span>;
passenger_max_instances_per_app <span style="color: #ff0000;">1</span>;
<span style="color: #adadad; font-style: italic;"># The maximum number of seconds that an application instance may be idle.</span>
<span style="color: #adadad; font-style: italic;"># That is, if an application instance hasn’t received any traffic after the given number of seconds,</span>
<span style="color: #adadad; font-style: italic;"># then it will be shutdown in order to conserve memory.</span>
passenger_pool_idle_time <span style="color: #ff0000;">3600</span>;
&nbsp;
<span style="color: #adadad; font-style: italic;"># Project 1</span>
server {
<span style="color: #00007f;">listen</span> <span style="color: #ff0000;">80</span>;
client_max_body_size 250M;
server_name project1.local;
root /Users/fred/rails/project1/public;
passenger_enabled <span style="color: #0000ff;">on</span>;
rails_env development;
access_log  /Users/fred/rails/project1/log/nginx.access.log;
error_log  /Users/fred/rails/project1/log/nginx.error.log info;
}
&nbsp;
<span style="color: #adadad; font-style: italic;"># Project 2</span>
server {
<span style="color: #00007f;">listen</span> <span style="color: #ff0000;">80</span>;
client_max_body_size 250M;
server_name project2.local;
root /Users/fred/rails/project2/public;
passenger_enabled <span style="color: #0000ff;">on</span>;
rails_env development;
access_log  /Users/fred/rails/project2/log/nginx.access.log;
error_log  /Users/fred/rails/project2/log/nginx.error.log info;
}
&nbsp;
<span style="color: #adadad; font-style: italic;"># Project 3</span>
server {
<span style="color: #00007f;">listen</span> <span style="color: #ff0000;">80</span>;
client_max_body_size 250M;
server_name project3.local;
root /Users/fred/rails/project3/public;
passenger_enabled <span style="color: #0000ff;">on</span>;
rails_env development;
access_log  /Users/fred/rails/project3/log/nginx.access.log;
error_log  /Users/fred/rails/project3/log/nginx.error.log info;
}
&nbsp;
<span style="color: #adadad; font-style: italic;"># And so on... as many projects as you want</span>
&nbsp;
}</pre></td></tr></table></div>

<p>Now edit your /etc/hosts and add the hosts for your local project</p>
<p>$ mate /etc/hosts</p>
<pre>

127.0.0.1   project1.local

127.0.0.1   project2.local

127.0.0.1   project3.local
</pre>
<p><strong>3. Start nginx</strong></p>
<p>sudo nginx</p>
<p><strong>4. go to your browser and open project1.local</strong></p>
<p><strong> <img src='http://www.frederico-araujo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p>
<p><strong>5. Easy start/restart/stop</strong></p>
<p>add this to your ~/.bash_profile file</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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> nginx_reload<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #007800;">FILE</span>=<span style="color: #ff0000;">&quot;/opt/local/logs/nginx.pid&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Reloading NGINX...&quot;</span>
<span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>nginx.pid<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-HUP</span> <span style="color: #007800;">$PID</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Nginx pid file not found&quot;</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> nginx_stop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #007800;">FILE</span>=<span style="color: #ff0000;">&quot;/opt/local/logs/nginx.pid&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping NGINX...&quot;</span>
<span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>nginx.pid<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-INT</span> <span style="color: #007800;">$PID</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Nginx pid file not found&quot;</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> nginx_restart<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #007800;">FILE</span>=<span style="color: #ff0000;">&quot;/opt/local/logs/nginx.pid&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping NGINX...&quot;</span>
<span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>nginx.pid<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-INT</span> <span style="color: #007800;">$PID</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting NGINX...&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> nginx
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Nginx pid file not found&quot;</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p><strong>Troubleshooting</strong></p>
<p>1. Nginx is not running</p>
<p>- check the logs</p>
<p>- check if it is really not running:</p>
<p>$ ps aux | grep nginx</p>
<p>2. you see the nginx error &#8220;502 Bad Gateway&#8221;</p>
<p>- may there is a problem with the /var/folders/ permissions on OSX:</p>
<pre>

2009/06/13 16:14:33 [crit] 1106#0: *1 connect() to unix:/var/folders/xl/xlSRYvzFHH8Fcehc51ciyE+++TI/-Tmp-//passenger.1091/master/helper_server.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: hassan.local, request: "GET / HTTP/1.1", upstream: "unix:/var/folders/xl/xlSRYvzFHH8Fcehc51ciyE+++TI/-Tmp-//passenger.1091/master/helper_server.sock:", host: "hassan.local"
</pre>
<p>to fix it I did this:</p>
<p>$ sudo find /var/folders/xl/ -name &#8220;master&#8221; -exec chmod 755 {} \;</p>
<p>$ sudo find /var/folders/xl/ -name &#8220;-Tmp-&#8221; -exec chmod 755 {} \;</p>
<p>everytime I reboot my mac I had to do that&#8230; I still dont know how to fix it&#8230;</p>
<p>anybody knows?</p>
<p>That is it for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2009/06/14/easy-installing-nginx-mod_rails-passenger-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop http Pipeline from overloading your server, using connlimit iptables</title>
		<link>http://www.frederico-araujo.com/2009/01/25/stop-http-pipeline-from-overloading-your-server-with-iptables/</link>
		<comments>http://www.frederico-araujo.com/2009/01/25/stop-http-pipeline-from-overloading-your-server-with-iptables/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 08:31:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=79</guid>
		<description><![CDATA[Have you edited or tweaked your pipeline settings in Firefox?
You can do it by typing about:config in your firefox url tab.
Most blogs and tutorial will tell you to set high values to improve the speed, such as this one: www.mydigitallife.info/2007/10/16/speed-up-your-firefox-by-adjusting-your-http-pipelining/
Many people will go crazy and make values even higher such as:
network.http.pipelining.maxrequests 32
network.http.max-persistent-connections-per-proxy 128
network.http.max-persistent-connections-per-server 128
network.http.max-connections-per-server 256
These [...]]]></description>
			<content:encoded><![CDATA[<p>Have you edited or tweaked your pipeline settings in Firefox?</p>
<p>You can do it by typing about:config in your firefox url tab.</p>
<p>Most blogs and tutorial will tell you to set high values to improve the speed, such as this one: <a href="http://www.mydigitallife.info/2007/10/16/speed-up-your-firefox-by-adjusting-your-http-pipelining/">www.mydigitallife.info/2007/10/16/speed-up-your-firefox-by-adjusting-your-http-pipelining/</a></p>
<p>Many people will go crazy and make values even higher such as:</p>
<p>network.http.pipelining.maxrequests 32<br />
network.http.max-persistent-connections-per-proxy 128<br />
network.http.max-persistent-connections-per-server 128<br />
network.http.max-connections-per-server 256</p>
<p>These settings are very high and will create at least 32 connections to your server.</p>
<p>if you have many images and SSI includes, it could overload your apache webserver.<br />
If you use apache2.2 with worker_mpm it will create 1 thread for each connection, thus you will have 32 new threads forked within just a few seconds.</p>
<p>Of course if you have a quad-core server with lots of ram you should not bother to read this.<br />
But for most cheap vps and single core servers, it can really help.</p>
<p>so how you do it? simple, just use iptables conn_limit module</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-I</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--syn</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-m</span> connlimit <span style="color: #660033;">--connlimit-above</span>  <span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> REJECT</pre></div></div>

<p>you may need to adjust the order or to insert or append like</p>
<p># to apped to the end of the INPUT chain:<br />
iptables -A input &#8230;<br />
or<br />
# to insert at position 10 of the input chain:<br />
iptables -I input 10 &#8230;</p>
<p>I have tested this schema and work very well with firefox pipeline freaks.</p>
<p>the server will only then take up to 8 simultaneously connections per IP</p>
<p>to test the established connections you can try with netstat from the server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-na</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> esta <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> 127.0.0.1 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> -t. <span style="color: #660033;">-k2</span></pre></div></div>

<p>Any comments, suggestions are welcome &#8230;</p>
<p>Update:</p>
<p>This can be not so good to legit users behind a proxy or firewall, because the the IP will be unique to all users behind the proxy/firewall.</p>
<p>in this case, you would increase the limit value.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2009/01/25/stop-http-pipeline-from-overloading-your-server-with-iptables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux script to collect system statistics and send to your email</title>
		<link>http://www.frederico-araujo.com/2009/01/08/linux-script-to-collect-system-statistics-and-send-to-your-email/</link>
		<comments>http://www.frederico-araujo.com/2009/01/08/linux-script-to-collect-system-statistics-and-send-to-your-email/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 08:11:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=67</guid>
		<description><![CDATA[This script I use to daily send me the system statistics on my gentoo server.
It will also reformat the output to replace tabs with 5 spaces so it will display nicely on your email client.
On mail.app the fonts Monaco and Inconsolata displays nicely, but the default font does not.
requirements:
- app-admin/sysstat
- net-mail/sendEmail
- app-admin/procinfo
- local postfix server [...]]]></description>
			<content:encoded><![CDATA[<p>This script I use to daily send me the system statistics on my gentoo server.<br />
It will also reformat the output to replace tabs with 5 spaces so it will display nicely on your email client.<br />
On mail.app the fonts Monaco and Inconsolata displays nicely, but the default font does not.</p>
<p>requirements:<br />
- app-admin/sysstat<br />
- net-mail/sendEmail<br />
- app-admin/procinfo<br />
- local postfix server able to deliver emails.<br />
- perl</p>
<pre>
emerge -va app-admin/sysstat net-mail/sendEmail app-admin/procinfo
</pre>
<p>I put the script under /etc/cron.daily</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">SERVER</span>=<span style="color: #ff0000;">&quot;mydomain.com&quot;</span>
<span style="color: #007800;">EMAIL_TO</span>=<span style="color: #ff0000;">&quot;your_email@gmail.com&quot;</span>
<span style="color: #007800;">EMAIL_FROM</span>=<span style="color: #ff0000;">&quot;amin@mydomain.com&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># logged in users and what are they running</span>
<span style="color: #007800;">WHO</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">w</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># processor stats</span>
<span style="color: #007800;">MPSTAT</span>=<span style="color: #000000; font-weight: bold;">`</span>mpstat<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># virtual memory stats</span>
<span style="color: #007800;">VMSTAT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">vmstat</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Top 20 memory hog applications</span>
<span style="color: #007800;">PS_MEM</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-A</span> <span style="color: #660033;">-o</span> pid,pcpu,pmem,start_time,state,<span style="color: #000000; font-weight: bold;">time</span>,<span style="color: #c20cb9; font-weight: bold;">comm</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'($_ = join &quot;&quot;,&lt;&gt;) =~ s/(\t)/     /g; print;'</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-g</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -<span style="color: #000000;">20</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Top 10 CPU usage applications</span>
<span style="color: #007800;">PS_CPU</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-A</span> <span style="color: #660033;">-o</span> pid,pcpu,pmem,start_time,state,<span style="color: #000000; font-weight: bold;">time</span>,<span style="color: #c20cb9; font-weight: bold;">comm</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'($_ = join &quot;&quot;,&lt;&gt;) =~ s/(\t)/     /g; print;'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-g</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">2</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -<span style="color: #000000;">10</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  memory usage in MB</span>
<span style="color: #007800;">FREE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">free</span> -m<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">PROCINFO</span>=<span style="color: #000000; font-weight: bold;">`</span>procinfo<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># iptables status</span>
<span style="color: #007800;">IPTABLES</span>=<span style="color: #000000; font-weight: bold;">`</span>iptables -nL<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># established connections</span>
<span style="color: #007800;">NETSTAT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-na</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> esta <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> 127.0.0.1 <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> -t. -k2<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># line divider</span>
<span style="color: #007800;">DL</span>=<span style="color: #ff0000;">&quot;==================================================================================&quot;</span>
&nbsp;
<span style="color: #007800;">FINAL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${DL}</span> 
<span style="color: #780078;">`date`</span>
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${SERVER}</span> 
<span style="color: #007800;">${DL}</span> 
<span style="color: #007800;">${WHO}</span> 
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${FREE}</span>
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${MPSTAT}</span>
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${VMSTAT}</span> 
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${PROCINFO}</span>
<span style="color: #007800;">${DL}</span> 
Top 10 CPU processes
<span style="color: #007800;">${PS_CPU}</span> 
<span style="color: #007800;">${DL}</span>
Top 20 Memory processes
<span style="color: #007800;">${PS_MEM}</span> 
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${IPTABLES}</span>
<span style="color: #007800;">${DL}</span>
<span style="color: #007800;">${NETSTAT}</span>
<span style="color: #007800;">${DL}</span>
&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${FINAL}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> 
  <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'($_ = join &quot;&quot;,&lt;&gt;) =~ s/(\t)/     /g; print;'</span> <span style="color: #000000; font-weight: bold;">|</span> 
  sendEmail <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${EMAIL_FROM}</span>&quot;</span> <span style="color: #660033;">-u</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SERVER}</span> comparator&quot;</span> <span style="color: #660033;">-t</span> <span style="color: #800000;">${EMAIL_TO}</span></pre></div></div>

<p>Resources:</p>
<p>- http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html<br />
- http://pagesperso-orange.fr/sebastien.godard/documentation.html<br />
- http://caspian.dotconf.net/menu/Software/SendEmail/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2009/01/08/linux-script-to-collect-system-statistics-and-send-to-your-email/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Blazing Fast Firefox using OSX RamDisk</title>
		<link>http://www.frederico-araujo.com/2008/12/18/blazing-fast-firefox-using-osx-ramdisk/</link>
		<comments>http://www.frederico-araujo.com/2008/12/18/blazing-fast-firefox-using-osx-ramdisk/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 09:32:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[osx]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ramdisk]]></category>
		<category><![CDATA[tmpfs]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=55</guid>
		<description><![CDATA[Firefox does a lot of IO to the disk even thou you have lots of spare Ram, due to Sqlite, Bookmarks, History and Cache.
To make Firefox faster is to store the whole profile folder into a Ram Disk.
RamDisk in Linux are called TmpFS. You can also use shared memory folder /dev/shm if you have it [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox does a lot of IO to the disk even thou you have lots of spare Ram, due to Sqlite, Bookmarks, History and Cache.</p>
<p>To make Firefox faster is to store the whole profile folder into a Ram Disk.<br />
RamDisk in Linux are called TmpFS. You can also use shared memory folder /dev/shm if you have it in your fstab.</p>
<p>This <a href="http://forums.gentoo.org/viewtopic.php?p=5319242"> post </a> in the gentoo forums explains how to do it in Gentoo linux.</p>
<p>I made a similar script to make it work in OSX Leopard.</p>
<p>The Script have 2 parts, Start.sh and Stop.sh<br />
Here are the Scripts:</p>
<p>Start.sh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Run this script to enable the Ramdisk for Firefox profiles</span>
<span style="color: #007800;">VolumeName</span>=<span style="color: #ff0000;">&quot;Mozilla&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Size in MB, make sure is not too low or not too high</span>
<span style="color: #007800;">SizeInMB</span>=<span style="color: #000000;">220</span>
&nbsp;
<span style="color: #007800;">NumSectors</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">1024</span><span style="color: #000000; font-weight: bold;">*</span>SizeInMB<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #007800;">DeviceName</span>=<span style="color: #000000; font-weight: bold;">`</span>hdid <span style="color: #660033;">-nomount</span> ram:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #007800;">$NumSectors</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$DeviceName</span>
&nbsp;
diskutil eraseVolume HFS+ RAMDisk <span style="color: #007800;">$DeviceName</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># move the current profiles folder</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> Profiles Profiles_ <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;
&nbsp;
<span style="color: #666666; font-style: italic;"># make a symlink to the ramdisk</span>
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>RAMDisk .<span style="color: #000000; font-weight: bold;">/</span>Profiles <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;
&nbsp;
<span style="color: #666666; font-style: italic;"># then copy it to the ramdisk</span>
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> Profiles_<span style="color: #000000; font-weight: bold;">/*</span> Profiles</pre></div></div>

<p>Stop.sh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Cache<span style="color: #000000; font-weight: bold;">/</span>Firefox<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># clean the cache</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span>  Profiles<span style="color: #000000; font-weight: bold;">/*/</span>Cache<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;
&nbsp;
<span style="color: #666666; font-style: italic;"># will save your modifications back to the DISK</span>
<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>rsync <span style="color: #660033;">-av</span> <span style="color: #660033;">--delete</span> .<span style="color: #000000; font-weight: bold;">/</span>Profiles<span style="color: #000000; font-weight: bold;">/</span> .<span style="color: #000000; font-weight: bold;">/</span>Profiles_<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;
&nbsp;
<span style="color: #666666; font-style: italic;"># sometimes during unmount it will say disk is in use.</span>
<span style="color: #666666; font-style: italic;"># make sure you close firefox before.</span>
<span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>RAMDisk <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> Profiles <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;
<span style="color: #c20cb9; font-weight: bold;">mv</span> Profiles_ Profiles</pre></div></div>

<p>You can also use &#8216;tar&#8217; instead of &#8216;rsync&#8217;. I just love rsync more.</p>
<p>* Warning: The ramdisk contents will be erased after you umount the ramdisk.</p>
<p>Have fun.</p>
<p><strong><a href="http://www.gentoo.org">Gentoo Linux ROCKS</a></strong></p>
<p>Update:</p>
<p>To speed up firefox even more  run these commands:</p>

<div class="wp_syntax"><div 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>Library<span style="color: #000000; font-weight: bold;">/</span>Caches<span style="color: #000000; font-weight: bold;">/</span>Firefox<span style="color: #000000; font-weight: bold;">/</span>Profiles
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*/*</span>.sqlite; <span style="color: #000000; font-weight: bold;">do</span> sqlite3 <span style="color: #007800;">$i</span> VACUUM;<span style="color: #000000; font-weight: bold;">done</span>;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Application\ Support<span style="color: #000000; font-weight: bold;">/</span>Firefox<span style="color: #000000; font-weight: bold;">/</span>Profiles
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*/*</span>.sqlite; <span style="color: #000000; font-weight: bold;">do</span> sqlite3 <span style="color: #007800;">$i</span> VACUUM;<span style="color: #000000; font-weight: bold;">done</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2008/12/18/blazing-fast-firefox-using-osx-ramdisk/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Getting Filevault on a HFS+ Case-Sensitive Filesystem</title>
		<link>http://www.frederico-araujo.com/2008/11/04/getting-filevault-on-a-hfs-case-sensitive-filesystem/</link>
		<comments>http://www.frederico-araujo.com/2008/11/04/getting-filevault-on-a-hfs-case-sensitive-filesystem/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 13:55:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[filevault]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=45</guid>
		<description><![CDATA[The OSX file vault feature will only let you activate it on your current home folder if you have a HFS+ case-insensitive file system. It will not let you activate it on a current HFS case-sensitive.
But there is a trick, when creating a &#8220;new&#8221; clean user it will allow you to enable filevault for that [...]]]></description>
			<content:encoded><![CDATA[<p>The OSX file vault feature will only let you activate it on your current home folder if you have a HFS+ case-insensitive file system. It will not let you activate it on a current HFS case-sensitive.</p>
<p>But there is a trick, when creating a &#8220;new&#8221; clean user it will allow you to enable filevault for that new user.</p>
<p>So, here is how you do it.</p>
<p>But before you try, make sure you have enough free space, try to get rid of huge files and folders, backup your data. (in this case, we will copy your data, so you will have 2 copies for safety)</p>
<p>Also clean your applications cache, such as firefox cache, camino, opera,<br />
~/Library/caches/com.apple.Safari/Webpage\ Previews/ , etc&#8230;: and close most of your applications.</p>
<p>$ cd ~/Library/Caches</p>
<p>$ find ./ -name &#8220;Cache&#8221; -exec rm -rf {} \;</p>
<p>$ rm -rf ~/Library/Caches/com.apple.Safari/Webpage\ Previews/Incoming/*</p>
<p>Steps</p>
<p>1. Create another admin user, for example &#8220;admin&#8221;, with administrator privileges</p>
<p>2. login as that user.</p>
<p>3. move your old user folder.</p>
<p>$ cd /Users/</p>
<p>$ sudo mv myusername myusername.bak</p>
<p>3. delete your old user from the &#8220;Accounts&#8221; preferences pane.</p>
<p>4. then create it again and check the option to use filevault</p>
<p>5. Logout from &#8220;admin&#8221;  and login again as newuser.</p>
<p>6. Now copy the old data to your home folder. ( will take a very long time for that)<br />
update: You must use rsync instead of cp, so that you also copy your VERY important hidden files. such as .ssh .gnupg .vimrc .gem .gitconfig  etc..</p>
<p>$ sudo /usr/bin/rsync -av /Users/myusername.bak/ /Users/myusername/</p>
<p># watch out if you have files that should not change the ownership, such as server backups.<br />
$ sudo chown -R  myusername ~/</p>
<p>7. Logout and login again, for your preferences to take effect</p>
<p>8. If everything looks fine, you might just delete the backup folder.</p>
<p>$ sudo rm -rf /Users/myusername.bak</p>
<p>if you have any confusions let me know in comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2008/11/04/getting-filevault-on-a-hfs-case-sensitive-filesystem/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>FastSleep or Hibernate on OSX Leopard? ;)</title>
		<link>http://www.frederico-araujo.com/2008/11/01/safesleep-fastsleep-or-hibernate-osx-leopard/</link>
		<comments>http://www.frederico-araujo.com/2008/11/01/safesleep-fastsleep-or-hibernate-osx-leopard/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 20:40:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.frederico-araujo.com/?p=22</guid>
		<description><![CDATA[First of all, what do I mean by safe sleep, fast sleep or hibernate?
Safe sleep is the way OSX sleeps to RAM and as well create a sleepimage (which is the size of your RAM). In case you run out of battery, so you can still resume from the image if the battery is dead, [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, what do I mean by safe sleep, fast sleep or hibernate?</p>
<p><strong>Safe sleep</strong> is the way OSX sleeps to RAM and as well create a sleepimage (which is the size of your RAM). In case you run out of battery, so you can still resume from the image if the battery is dead, (and you have plugged it in <img src='http://www.frederico-araujo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Provides very fast wake up, uses the battery while sleeping.</p>
<p><strong>Fast Sleep</strong> is just sleep to RAM, same as safe sleep but no image creation, and if your battery is dead, the mac will cold boot. Provides very fast wake up same as safe sleep, uses the battery while sleeping.</p>
<p><strong>Hibernate</strong> is when it uses the sleepimage all the time. Slower sleep and slow wake up, but it does not use battery at all&#8230;</p>
<p>So&#8230;</p>
<p>I found in this website <a href="http://alt.cc/jk/2007/08/07/safe-sleep-addendum/">http://alt.cc/jk/2007/08/07/safe-sleep-addendum/</a> this nice script that handles when to FastSleep or when to Hibernate.</p>
<p>you can get safe sleep with the command  &#8220;$ sudo pmset hibernate 3&#8243;</p>
<p>I have modified the script it little :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">MODE</span>=<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>pmset <span style="color: #660033;">-g</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> hibernatemode <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $2 }'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">LEFT</span>=<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>pmset <span style="color: #660033;">-g</span> batt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Internal <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $2 }'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">%</span> <span style="color: #ff0000;">'{ print $1 }'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">HIBERNATE</span>=<span style="color: #000000;">20</span>
<span style="color: #007800;">FASTSLEEP</span>=<span style="color: #000000;">50</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Running safesleep.sh =&gt; MODE: <span style="color: #007800;">${MODE}</span> LEFT: <span style="color: #007800;">${LEFT}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$LEFT</span> <span style="color: #660033;">-lt</span> <span style="color: #007800;">$HIBERNATE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$MODE</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Less than <span style="color: #007800;">${HIBERNATE}</span>% remains&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Setting Hibernate (hibernate mode 1)&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
		<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>pmset <span style="color: #660033;">-a</span> hibernatemode <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #007800;">LS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-al</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>sleepimage<span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The sleepimage should be created:&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LS}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #000000; font-weight: bold;">elif</span>  <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$LEFT</span> <span style="color: #660033;">-gt</span> <span style="color: #007800;">$FASTSLEEP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$MODE</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Greater than <span style="color: #007800;">${FASTSLEEP}</span>% remains&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Setting FastSleep (hibernate mode 0)&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</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>system.log
		<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>pmset <span style="color: #660033;">-a</span> hibernatemode <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>sleepimage<span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>save it as /Users/your_user_name/.crons/safesleep.sh</p>
<p>now make it permanent in a crontab to run every 10 minutes, but wait, anacron (osx default cron) only supports daily/weekly/monthly jobs! (unless you patch it)</p>
<p>I guess we&#8217;ll have to install fcron:</p>
<p>$ sudo port -d install fcron</p>
<p>$ sudo vi /opt/local/etc/fcrontab</p>
<p><code><br />
@,runas(root) 10 sh /Users/your_user_name/.crons/safesleep.sh<br />
</code></p>
<p>$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.fcron.plist</p>
<p>$ sudo launchctl start org.macports.fcron</p>
<p>that&#8217;s it.</p>
<p>enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2008/11/01/safesleep-fastsleep-or-hibernate-osx-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A new Virtual machine by Sun, Free!</title>
		<link>http://www.frederico-araujo.com/2008/11/01/a-new-virtual-machine-by-sun-free/</link>
		<comments>http://www.frederico-araujo.com/2008/11/01/a-new-virtual-machine-by-sun-free/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 19:33:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<guid isPermaLink="false">http://wp.frederico-araujo.com/?p=18</guid>
		<description><![CDATA[I just found the new Virtual Machine Software released by SUN Microsystems. It&#8217;s called VirtualBox.
 http://virtualbox.org 
VirtualBox runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of Guest Operating systems.
Im running windows XP on my macbook pro and it seems ok, thou OSX is really slow, when I run the virtual [...]]]></description>
			<content:encoded><![CDATA[<p>I just found the new Virtual Machine Software released by SUN Microsystems. It&#8217;s called VirtualBox.</p>
<p><a href="http://virtualbox.org"> http://virtualbox.org </a></p>
<p>VirtualBox runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of Guest Operating systems.</p>
<p>Im running windows XP on my macbook pro and it seems ok, thou OSX is really slow, when I run the virtual machine. (and yes, I install virtual box drivers and tools on the guest)</p>
<p>here is some VirtualBox Goodnes that explains baout the command line tool:</p>
<p><a href="http://dkprojects.wordpress.com/2008/10/29/more-virtualbox-goodness-tackling-the-cli/"> http://dkprojects.wordpress.com/2008/10/29/more-virtualbox-goodness-tackling-the-cli/ </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2008/11/01/a-new-virtual-machine-by-sun-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A little Haml tutorial on how to render different formats</title>
		<link>http://www.frederico-araujo.com/2008/08/19/a-little-haml-tutorial-on-how-to-render-different-formats/</link>
		<comments>http://www.frederico-araujo.com/2008/08/19/a-little-haml-tutorial-on-how-to-render-different-formats/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 17:00:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.frederico-araujo.com/?p=8</guid>
		<description><![CDATA[Suppose you have a Model called Article that contains a text field and a format field.
You would like to use haml, textile or HTML to edit your Article from the admin interface.

  create_table &#34;articles&#34;, :force =&#62; true do &#124;t&#124;
    t.string   &#34;title&#34;
    t.text     [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a Model called Article that contains a text field and a format field.</p>
<p>You would like to use haml, textile or HTML to edit your Article from the admin interface.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  create_table <span style="color:#996600;">&quot;articles&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:force</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    t.<span style="color:#CC0066; font-weight:bold;">string</span>   <span style="color:#996600;">&quot;title&quot;</span>
    t.<span style="color:#9900CC;">text</span>     <span style="color:#996600;">&quot;body&quot;</span>
    t.<span style="color:#CC0066; font-weight:bold;">string</span>   <span style="color:#996600;">&quot;formatting_type&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span>, <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;HTML&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>app/models/article.rb</p>
<p>It’s quite simple. All you have to do is to add this helper in your application_helper.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> print_formated<span style="color:#006600; font-weight:bold;">&#40;</span>type,text<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">case</span> type
    <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#996600;">&quot;HTML&quot;</span>
      text
    <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#996600;">&quot;Plain Text&quot;</span>
      h text
    <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#996600;">&quot;HAML&quot;</span>
      <span style="color:#6666ff; font-weight:bold;">Haml::Engine</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">render</span>
    <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#996600;">&quot;Syntaxy&quot;</span>
      Syntaxi.<span style="color:#9900CC;">line_number_method</span> = <span style="color:#996600;">'none'</span>
      Syntaxi.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">process</span>
    <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#996600;">&quot;Textile&quot;</span>
      RedCloth.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_html</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>In your views/articles/_form.haml add the select field.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  = label <span style="color:#ff3333; font-weight:bold;">:article</span>, <span style="color:#ff3333; font-weight:bold;">:formatting_type</span>
  = <span style="color:#CC0066; font-weight:bold;">select</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:article</span>, <span style="color:#ff3333; font-weight:bold;">:formatting_type</span>, <span style="color:#6666ff; font-weight:bold;">Article::FORMATTING_TYPES</span>.<span style="color:#9900CC;">collect</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">p</span> <span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:include_blank</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Then in the Show view (articles/show.haml)</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">&nbsp;
.<span style="color:#9900CC;">article</span>
  .<span style="color:#9900CC;">title</span>
    <span style="color:#006600; font-weight:bold;">%</span>h1
      = h <span style="color:#0066ff; font-weight:bold;">@article</span>.<span style="color:#9900CC;">title</span>
  .<span style="color:#9900CC;">body</span>
    = print_formated<span style="color:#006600; font-weight:bold;">&#40;</span>@article.<span style="color:#9900CC;">formatting_type</span>, <span style="color:#0066ff; font-weight:bold;">@article</span>.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>that’s pretty much it.<br />
 <img src='http://www.frederico-araujo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2008/08/19/a-little-haml-tutorial-on-how-to-render-different-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy installing Passenger mod_rails on gentoo Linux</title>
		<link>http://www.frederico-araujo.com/2008/08/06/easy-installing-passenger-mod_rails-on-gentoo/</link>
		<comments>http://www.frederico-araujo.com/2008/08/06/easy-installing-passenger-mod_rails-on-gentoo/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 05:15:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mod_rails]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=35</guid>
		<description><![CDATA[To install the great Mod_Rails on Gentoo linux it&#8217;s as easy as 5 steps.
Since you are Gentoo user, i don&#8217;t need to go to details. You know what you doing.  
Update: Mod-rails now works with apache mpm-worker
1. Recompile Apache non-threaded
add this to /etc/portage/package.use
www-servers/apache -threads
and this to /etc/make.conf
APACHE2_MPMS="prefork"
2. Re emerge apache
# emerge -va apache
3. Passenger [...]]]></description>
			<content:encoded><![CDATA[<p>To install the great Mod_Rails on Gentoo linux it&#8217;s as easy as 5 steps.</p>
<p>Since you are Gentoo user, i don&#8217;t need to go to details. You know what you doing. <img src='http://www.frederico-araujo.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong><em>Update</em></strong>: Mod-rails now works with apache mpm-worker</p>
<h4><span style="text-decoration: line-through;">1. Recompile Apache non-threaded</span></h4>
<p><span style="text-decoration: line-through;">add this to /etc/portage/package.use</span></p>
<pre><span style="text-decoration: line-through;">www-servers/apache -threads</span></pre>
<p><span style="text-decoration: line-through;">and this to /etc/make.conf</span></p>
<pre><span style="text-decoration: line-through;">APACHE2_MPMS="prefork"</span></pre>
<h4><span style="text-decoration: line-through;">2. Re emerge apache</span></h4>
<pre><span style="text-decoration: line-through;"># emerge -va apache</span></pre>
<h4>3. Passenger is in gentoo portage, but its in testing. Currently Version 2.0.1</h4>
<pre># echo "www-apache/passenger" &gt;&gt; /etc/portage/package.keywords</pre>
<h4>4. Install Passenger</h4>
<pre># emerge -va passenger</pre>
<p>If it tries to install rails 2.2.2, rake, and lots of other gems that you already have installed trough rubygems, then run emerge with &#8211;nodeps option</p>
<pre># emerge -va --nodeps passenger</pre>
<h4>5. Edit /etc/conf.d/apache and add &#8220;-D PASSENGER&#8221; to apache options</h4>
<p>for example mine looks like this:</p>
<pre>APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D PROXY -D PASSENGER"</pre>
<p>That&#8217;s it.</p>
<p>Now just drop a similar vhost config file inside /etc/apache/vhosts.d/</p>
<p>This is a sample vhost file for a rails app.</p>
<pre>&lt;VirtualHost *:80&gt;
  ServerName mydomain.com
  DocumentRoot /myapp/public
  Include /etc/apache2/vhosts.d/deflate.conf
  RailsBaseURI /
  # The maximum number of Ruby on Rails application instances that may be simultaneously active.
  # A larger number results in higher memory usage, but improved ability to handle concurrent HTTP clients.
  # normally 1 to 10. (1 for each 50mb ram)
  RailsMaxPoolSize 1
  # The maximum number of seconds that a Ruby on Rails application instance may be idle.
  # That is, if an application instance hasn't done anything after the given number of seconds,
  # then it will be shutdown in order to conserve memory. ( 1 hour)
  RailsPoolIdleTime 3600
  RailsEnv 'production'
  &lt;Directory /myapp/public&gt;
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<p>My sample deflate.conf,<br />
used to gzip the content</p>
<pre>&lt;Location /&gt;
	SetOutputFilter DEFLATE
	#
	# Netscape 4.x has some problems...
	BrowserMatch ^Mozilla/4 gzip-only-text/html
	#
	# Netscape 4.06-4.08 have some more problems
	BrowserMatch ^Mozilla/4\.0[678] no-gzip
	#
	# MSIE masquerades as Netscape, but it is fine
	BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
	# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
	# the above regex won't work. You can use the following
	# workaround to get the desired effect:
	BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
	# Don't compress images
	SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
	SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
	SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
	# Make sure proxies don't deliver the wrong content
	Header append Vary User-Agent env=!dont-vary
&lt;/Location&gt;

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
CustomLog /var/log/apache2/deflate_log deflate</pre>
<p>* Update on July 10, 2008.</p>
<p>- Now using gentoo portage to install it. it&#8217;s more smooth.</p>
<p>Note:</p>
<p>Personally I found that Thin + nginx uses less memory(Nginx 4MB + each thin server) than<br />
apache + passenger, which uses quite more. (Apache: 50MB + each rails spawner)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2008/08/06/easy-installing-passenger-mod_rails-on-gentoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
