Thursday 30 September 2010

Query to select last observation by date for each customer

Sometimes you have a table with a list of transactions of each, say, customer and you need the latest picture of each customer. The so called window functions in SQL2003 are instrumental in order to write neat, concise SQL for such purpose.

It would work as follows (in Teradata's SQL dialect):

select
  cust_id,
  status,
  status_date,
row_number() over (partition by cust_id order by status_date desc ) as ranking
from customer_status
qualify ranking = 1;

Saturday 25 September 2010

Relaying Postfix SMTP via smtp.gmail.com

You just need to follow these instructions to relay Postfix mail via smtp.gmail.com. You just need to be careful that some packages mentioned there have updated their names in recent Ubuntu versions: for instance, package libsasl2 mentioned there is now (as of today!) called libsasl2-2. 

Other than that, it works as a charm!

Saturday 11 September 2010

Run BOINC on a Windows box without Internet connection

If you have access to a Windows box without internet connection on which you wish to run BOINC, you can do as follows:
  1. Install BOINC on another Windows box with internet connection and register to your project(s).
  2. Copy the BOINC folder (possibly at C:\Program Files\BOINC) to your pen-drive. You may want to uninstall BOINC from this machine at this point.
  3. Navigate to the BOINC folder in your pendrive, and run the boinc executable file in order to download new tasks. Try to get as many as you can by setting the BOINC options adequately.
  4. Plug your pen-drive to the machine without internet connection and run the boinc executable file from it. Your tasks will start running. Those finishing will stay there waiting to be transferred back to the project servers.
  5. When the tasks have finished (or when you see fit!) unplug the pen-drive, plug it back to the machine with internet connection and see your tasks be uploaded to the project servers.
Note: beware of the submit time limit for tasks so that they do not expire.