Archive for June, 2007

Our good and extremly competent friends at Bearstech saw my post about Geo encoding (Retrouver par code postal tous les lieux qui sont du même dépratement, de la même région ou de la même ville (mysql, php)) of French data and decided, this was no way to go around this! So Vincent Caron decided to create for all those interested a great GPLed package to help you will all your geocoding woes for France! so go over to the Bearstech forge (http://forge.bearstech.com/) where you can download the package or browse the php source code through the trac SVN interface.

Geo-Data (France) ¶
Features ¶

This is a compilation of simple administrative and geographic informations for France, up to the city and district level:

* 32,856 cities with their official zipcode and préfecture flag. Paris, Lyon and Marseille are split into arrondissements.
* 96 départements, 6 DOM and 3 TOM (within the same hierarchical level). Proper keying is used (ie. 2A for Corse du Sud, no “20″ or “97″ shortcuts).
* 22 régions, with two supplementary to classify départements from DOM and TOM.

Redundant data in all tables help make you sure you can all information available in a single SELECT lookup:

* asking for a département gives its région
* asking for a city also gives its corresponding département and région

Note: the city database might be incomplete, our source was not properly time stamped.
History ¶

This compilation of PHP and SQL code was extracted from a production real-estate web site, which uses extensively this geographical data to search, filter and match people wishes with other’s desires.

The data was collected from various public french sources and meticulously, patiently reworked and modified by Bearstech according to professionnals and users feedback while using the data.
Copyright ¶

Click to continue reading

How to run several instances of a rails app with a single code base?

What is the problem?

Sometimes you want to run several instances of the same application on your server. How to easily do this in rails?

The solution :)

Rails offers us the environments, allowing to run an application under different status: development, test or production environment.

We just have to create in the database.yml a specific database connection for each new environment:

prod1:
  adapter: mysql
  database: prod_one
  username: root
  password: password

and for another instance

prod2:
  adapter: mysql
  database: prod_two
  username: root
  password: password

and to create a specific configuration file ‘prod1.yml’ in the directory config/environments/.

After this, you just generate the database schema with the following command:

rake db:migrate RAILS_ENV=prod1

And run the server on a specified port:

./script/server -p 4001 -e prod1

Et voilà! an instance running on the specified port (4000).

If you want another one (let’s say prod2).

Let’s create the database instance… rake db:migrate RAILS_ENV=prod2

./script/server -p 4002 -e prod2 … and another instance of the same code base is now running on port 4002.

Bliss.

Click to continue reading

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.0 License.