Fork me on GitHub

Rails and PostgreSQL

Complaining, screaming, sweating, swearing …. why it doesnt work … jeeeeeezzz/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in `establish_connection': Please install the postgres adapter: `gem install activerecord-postgres-adapter` (no such file to load -- active_record/connection_adapters/postgres_adapter) (RuntimeError)

And then a light … “I upgraded postgresql recently!”

Just reinstall the postgres gem and you are done…

What a night!

map and grep: from Perl to PHP

Probably many of you already know but here is the correspondent in PHP of the two fundamentals Perl functions:
map => array_map
grep => array_filter

Too lazy to give you examples .. I think you can work it out yourself.

;)

PHP-FPM on Ubuntu Lucid Lynx

I have been using the dotdeb repository on karmic for a while, but today, when I installed the new Lucid Lynx, it just became a mess so I decided to keep all the original ubuntu packages (Lucid ships php 5.3.2) and find an alternative repo for php-fpm which I use on my dev machine.
Here it is:Brian’s php5-fpm : Brian Mercer

Happy 10.04! :)

Google Website Optimiser and the bugged Techie Guide

I spent hours yesterday to implement the GWO that, instead, should take literally minutes!
You want to know why? The bugged Techie Guide!!!

On page 19, the script is completely wrong and drove me mad: variation-content should be variation_content and document.write(“</nosc” + “ript>”) should be document.write(“<nosc” + “ript>”);

So, here is he complete correct script:
<script>
var v = utmx(‘variation_content’, ‘Section1’);
if (v) {
document.write(
v.replace(“%%product_name%%”, “<? print $product_name ?>”).
replace(“%%product_price%%”, “<? print $product_price ?>”).
replace(“%%product_id%%”, “<? print $product_id ?>”));
document.write(“<nosc” + “ript>”);
}
</script>
<ul>
<li>Product name: <? print $product_name ?>
<li>Product price: <? print $product_price ?>
<li><a href=’buy.php?prod-id=<? print $product_id ?>’>
Buy Now</a>
</ul>
</noscript>

Adapt it to your code and be happy!

Nginx and $_SERVER['HTTPS']

When you are using the FastCGI Php version, you would set HTTPS variable if you are serving parts of you website with SSL.
To do that, add the following function into the http section of your nginx configuration
map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;
}

and use the variable into your server section
fastcgi_param HTTPS $fastcgi_https;

Lazy explanation as usual :P

svn: Inconsistent line ending style

I hate svn! It’s official!
if you have this stupid error, what you have to do is run dos2unix on the file specified by the error. Don’t forget the -a option!
shell$ dos2unix -a /the/affected/file.php

upstream sent too big header while reading response header from upstream

if you have this error from nginx with php-fpm and output_buffers = On in your php.ini then try to increment the buffer size in nginx:

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

BASH: rename files

A simple rename example using again the mighty awk and xargs
ls -l *.xml | awk '{print $9}' | xargs -t -i mv {} {}.old

Explanation:
ls -l *.xml -> easy! list the xml files in a folder
awk '{print $9}' -> output just the name of the file
xargs -t -i mv {} {}.old -> rename it adding at the same filename the extension “.old”

I know, I know … my explanation is crap: blame my laziness :)

disable Pure-ftpd logging on syslog

Pure-ftpd is a bit tricky to configure because do not handle the configuration like any other daemon in Linux so you will not find any /etc/pure-ftpd.conf.

According to the pure-ftpd documentation, you should start the daemon already with the options you need. The default Ubuntu installation, use the files in /etc/pure-ftpd/conf/ to set the options for the startup script of pure-ftpd so, to disable the logging, execute the following command in your shell and restart the daemon
$ echo "none" > /etc/pure-ftpd/conf/SyslogFacility
$ /etc/init.d/pure-ftpd-mysql restart

;)

Firefox 3.6 stable on Karmic

I’ll just paste here the usual simple steps to install the latest firefox 3.6 on your ubuntu:

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get install firefox-3.6

Have fun ;)