After a week of “502 Bad Gateway” error on blog.feevy.com, it was time to dive in our new Nginx toy on Feevy server and understand what happened.

First, Nginx is not like Apache or Lighttpd, it doesn’t support FastCGI by default. So, you need to be sure you’ve compiled the fcgi module with your PHP installation.

On Centos, to compile a new PHP, just launch: /scripts/easyapache

Then you’ll need to launch the FastCGI process, download this FastCGI script, place it in /usr/local/bin, and add it to your init.d.

At the end, you just need to configure your php server in nginx, that would be the most simple part:

  server {
      listen 80;
      server_name     blog.feevy.com;
      index           index.php;
      root            /home/wwwfeev/blog;

      if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?q=$1  last;
        break;
      }

      location ~ .php$ {
         fastcgi_pass  127.0.0.1:9999;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_NAME $fastcgi_script_name;
         fastcgi_param REQUEST_URI $request_uri;
         fastcgi_param DOCUMENT_URI $document_uri;
         fastcgi_param DOCUMENT_ROOT $document_root;
         fastcgi_param REMOTE_ADDR $remote_addr;
         fastcgi_param REMOTE_PORT $remote_port;
         fastcgi_param SERVER_ADDR $server_addr;
         fastcgi_param SERVER_PORT $server_port;
         fastcgi_param SERVER_NAME $server_name;
         fastcgi_param SCRIPT_FILENAME  /home/wwwfeev/blog/$fastcgi_script_name;
         fastcgi_param QUERY_STRING $query_string;
         fastcgi_param REQUEST_METHOD $request_method;
         fastcgi_param CONTENT_TYPE $content_type;
         fastcgi_param CONTENT_LENGTH $content_length;
      }
  }

Sorry for all the people who couldn’t watch the Reprap move in 3D last friday in Bilbao, it’s finally working tonight!

The code to control the robot is really elegant, and it was not really hard to find the missing part to make it work properly.
I’ve also add a setMax() method on the axises, so the hardware opto-endstop are not needed anymore. but it’ll be cool to keep them just to use them to set the print-header home. I think I’ve seen some example like this somewhere, but I’m not usre yet how it works.

People interesting in downloading/cloning/forking the Arduino firmware for Reprap can go to the project page on Github.

[Textmate] Arduino Bundle

After first days with the Darwin machine, it became clear that something was needed to replace the current Arduino software and upload the RepRap firmware directly from Textmate.

So here comes my first Textmate Bundle, thanks to the elegant work of Arduino team to make it easier to upload program from command line:

Arduino.tmbundle

Once installed, only one shortcut is available to make and upload your program on the Arduino board: Command-Shift-A

You can clone/fork the project from Github too, make your own repository and I’ll be glad to add your patch to the current simple bundle.
And come back during the week, you’ll surely see some update during the intensive RepRap hack session!

On the way to launch Live Clöthing, I had to hack this morning the register action hooks for WordPress, that don’t work as simply as excepted.

‘register_post’ action

You won’t be able to add more errors in $errors if you do not make it global in register_new_user() of wp-login.php:

function register_new_user($user_login, $user_email) {
global $errors;

‘user_register’ action

For some strange reason, $user_id is not available, you’ll need to add this hack to read it in your hook function:

$user_id = (int) func_get_arg( 0 );

[Jabber] Delicious Bot

Because when I see a good link, my main pleasure is to send it to as many friends as possible on IM, here is a simple jabber bot I could use to also save these links to my delicious account:

Download from github.com

It uses jabber-bot and rdelicious gem for ruby, you just need to configure the config.yml with your jabber and delicious login information and maje it run with:

ruby delicious-bot.rb

The bot will connect to the master jabber you’ve configured in the config.yml, and you just need to send him the bookmark command:

bookmark url description

You can add your commands easily inside the bot, and fork the project from Github.com:

Delicious-bot project on github.com

We are going to use our own openid server for various projects, it was fairly easy to install at then end.

Because sources are diffused on the net, here is a all-in-one package you’ll just need to put on your webhost to start your server:

Download package

Update: OpenId-Server now on Github.com

Configuration

In the package, you need to edit some configuration in web/config.php:

/**
 * The administrator's email address.  You may leave this empty if you
 * wish.  If empty, the "Contact (email address)" message will not
 * appear on every page footer.
 */
define('SITE_ADMIN_EMAIL', "admin@example.com");

/**
 * Set these values for administrative access.  This account will be
 * able to create and remove accounts from the auth backend.  This
 * username will not be permitted to use an OpenID.  The password MUST
 * be an MD5 hexadecimal hash of the password you want to use.
 * Example:
 *
 * define('ADMIN_PASSWORD_MD5', '21232f297a57a5a743894a0e4a801fc3');
 *
 */
define('ADMIN_USERNAME', 'admin');
define('ADMIN_PASSWORD_MD5', '');

Visit this page to transform your password in MD5 hash

/**
 * Storage backend to use.  Currently the only choice is "MYSQL".  See
 * storage.php for storage backend implementations.  Parameters for
 * connecting to the storage backend.  See storage.php if you want to
 * create your own backend.
 */
define('STORAGE_BACKEND', 'MYSQL');
global $storage_parameters;
$storage_parameters = array('username' => 'openid',
                            'password' => '',
                            'database' => 'php_openid_server',
                            'hostspec' => 'localhost');

There are more options you can change in config.php, feel free to experiment :)

Link to HTTP server

You need to tell to your server to access OpenID server in the ‘web‘ directory.
Here is how it works on my webhost:

ln -sf ~/openid/web/ ~/public_html/openid/

Now you can access my OpenID server on http://openid.alexgirard.com

Indian Weekend in Asturias

Here is the video made by David from the rushes of our weekend with Mercedes in Asturias to meet Maki, a new Indianos.

Everything was perfect: cider bars, local food, hiking in the mountain, asturian connection y dulce alegria!

PS: estoy pensando en español cuando quierre escribir algo, probablemente vais a ver un cambio de idioma en los proximas semanas :)

[Git] Gitorious on Ubuntu

This is the bash history to install and run Gitorious on a Ubuntu server (you need ruby-dev, rails, mongrel and git-core installed to continue).

Some pitfalls:

  • Texpow is not installing because of Onigurama, so download it and build it from sources
  • Problem: “cannot open shared object file: No such file or directory – /usr/lib/ruby/gems/1.8/gems/oniguruma-1.1.0/lib/oregexp.so“. Solution: sudo ldconfig
git clone git://gitorious.org/gitorious/mainline.git  gitorious
cd gitorious
sudo apt-get install libopenssl-ruby1.8
sudo gem install mime-types textpow -y
cp config/gitorious.sample.yml config/gitorious.yml; nano config/gitorious.yml
nano config/database.yml
rake db:migrate
mongrel_rails start

Then open your browser to http://localhost:3000

During the rewritting of Feevy.com with Merb, I’m discovering RSpec, a framework to be sure your code behave nicely.

Follow and join Feevy rewrite on Gitorious

Instead of normal test-units, you describe how your app/model should behave, which give a more-human conversation when you read your test:

  it "should create a feed from website http://blog.feevy.com" do

    feed = Feed.new :website => "http://blog.feevy.com"

    feed.valid?(:save).should == true

    feed.link.should == "http://blog.feevy.com/feed/"
    feed.website.should == "http://blog.feevy.com"
    feed.title.should == "Feevy Blog"

  end

To re-initialize your database between each test:

  before(:each) do
      Feed.delete_all
  end

Next step: writing Feevy stories