Using Different PostgreSQL Versions at The Same Time.
When I work for multiple clients on multiple different projects, I usually need a bunch of different stuff on my machine. One of the things I need is having multiple PostgreSQL versions installed.
I use Ubuntu 12.04. Installing PostgreSQL there is quite easy. Currently there are available two versions out of the box: 8.4 and 9.1. To install them I used the following command:
~$ sudo apt-get install postgresql-9.1 postgresql-8.4 postgresql-client-commonNow I have the above two versions installed.
Starting the database is also very easy:
~$ sudo service postgresql restart
* Restarting PostgreSQL 8.4 database server [ OK ]
* Restarting PostgreSQL 9.1 database server [ OK ]The problem I had for a very long time was using the proper psql version. Both database installed their own programs like pg_dump and psql. Normally you can use pg_dump from the higher version PostgreSQL, however using different psql versions can be dangerous because psql uses a lot of queries which dig deep into the PostgreSQL internal tables for getting information about the database. Those internals sometimes change from one database version to another, so the best solution is to use the psql from the …
postgres ubuntu
Hidden inefficiencies in Interchange searching
A very common, somewhat primitive approach to Interchange searching uses an approach like this:
The search profile contains something along the lines of
mv_search_type=db
mv_search_file=products
mv_column_op=rm
mv_numeric=0
mv_search_field=category
[search-region]
[item-list]
[item-field description]
[/item-list]
[/search-region]In other words, we search the products table for rows whose column “category” matches an expression (with a single query), and we list all the matches (description only). However, this can be inefficient depending on your database implementation: the item-field tag issues a query every time it’s encountered, which you can see if you “tail” your database log. If your item-list contains many different columns from the search result, you’ll end up issuing many such queries:
[item-list]
[item-field description], [item-field weight], [item-field color],
[item-field size], [item field ...]
...resulting in:
SELECT description FROM products WHERE sku='ABC123'
SELECT weight FROM products WHERE sku='ABC123'
SELECT color FROM products WHERE sku='ABC123'
SELECT size FROM products WHERE sku='ABC123'
... …interchange
Rails 3 ActiveRecord caching bug ahoy!
Sometimes bugs in other people’s code makes me think I might be crazy. I’m not talking Walter Sobchak gun-in-the-air-and-a-Pomeranian-in-a-cat-carrier crazy, but “I must be doing something incredibly wrong here” crazy. I recently ran into a Rails 3 ActiveRecord caching bug that made me feel this kind of crazy. Check out this pretty simple caching setup and the bug I encountered and tell me; Am I wrong?
I have two models with a simple parent/child relationship defined with has_many and belongs_to ActiveRecord associations, respectively. Here are the pertinent bits of each:
class MimeTypeCategory < ActiveRecord::Base
# parent class
has_many :mime_types
def self.all
Rails.cache.fetch("mime_type_categories") do
MimeTypeCategory.find(:all, :include => :mime_types)
end
end
class MimeType < ActiveRecord::Base
# child class
belongs_to :mime_type_category
endNotice how in MimeTypeCategory.all, we are eager loading each MimeTypeCategory’s children MimeTypes because our app tends to use those MimeTypes any time we need a MimeTypeCategory. Then, we cache that entire data structure because it’s a good candidate for caching and we like our app to be fast. …
ruby rails tips
Postgres Open 2012
I’m excited to be speaking at the 2012 Postgres Open Conference; Chicago, September 17-19. (Conference details at http://www.postgresopen.org/.)
My talk will be “Choosing a Logical Replication System: Slony vs Bucardo”.
I look forward to seeing many of you there!
conference postgres
Ruby on Rails software developer needed
This position has been filled. See our active job listings here.
We’re looking for another talented Ruby on Rails developer to consult with our clients and develop their Ruby on Rails web applications. If you like to focus on solving business problems and can take responsibility for getting a job done well without intensive oversight, please read on!
End Point is a 17-year-old web consulting company based in New York city, with 28 full-time employees working mostly remotely from home offices. Our team is made up of strong ecommerce, database, and system administration talent, working together using ssh, Screen and tmux, IRC, Google+ Hangouts, Skype, and good old phones.
We serve over 200 clients ranging from small family businesses to large corporations, using a variety of open source technologies including Ruby, Python, Perl, Git, PostgreSQL, MySQL, RHEL/CentOS, Debian, and Ubuntu.
What is in it for you?
- Work from your home office
- Flexible full-time work hours
- Annual bonus opportunity
- Health insurance benefit
- 401(k) retirement savings plan
- Ability to move without being tied to your job location
What you will be doing:
- Consult with clients to determine their web application needs
- Build, test, release, and maintain web applications for our …
jobs-closed rails
Are you sure you want a MacBook Pro?
The “UltraBooks” trend has been been made popular by Apple’s efforts at making the computer an appliance. There are clear benefits to this, but for enthusiasts, it means less control to upgrade to hardware of their choosing. Let’s contrast this experience with my own Dell Vostro 3500. It was purchased two years ago and yet through upgrades, it has many features the recently refreshed MacBook Pro with Retina display lacks, while offering the same processing power.
MacBook Pro Advantages
Let’s be clear, the MacBook Pro (MBP) has a number advantages over my Dell. The Retina display of course trounces my 1376×768 resolution on a 15" display. For designers, photographers, and video editors, Retina is a great asset. For someone who spends their day inside Vim and SSH, not so much. Similarly, the MBP’s seven hour battery life is impressive, although I’m sure with my processor intensive work load, it would be lower. But for me, I’m not terribly mobile. I need to be mobile from room to room perhaps, but I don’t find myself without power and needing to complete mission critical work less frequently than my replaceable 90 watt-hour battery can provide over 3 to 4 hours. Similarly, weight …
linux mac hardware
Interchange “on-the-fly” items
Interchange has a handy feature (which, in my almost-seven-years of involvement, I’d not seen or suspected) allowing you to create an item “on-the-fly”, without requiring any updates to your products table. Here’s a recipe for making this work.
First, you need to tell Interchange that you’re going to make use of this feature (in catalog.cfg).
OnFly onflySimple, no? The “OnFly” directive names a subroutine that is called to pre-process the custom item before it’s added to the cart. The default “onfly” routine can be found in the system tag “onfly”: code/SystemTag/onfly.coretag in the standard Interchange installation. (If you need more that what it provides, that’s beyond the scope of my post, so good luck, bon voyage, and please write back to let us know what you learned!)
Then, you need to submit some special form parameters to set up the cart:
- mv_order_item: the item number identifying this line
- mv_order_fly: a structured string with | (vertical bar) delimiters. Each sub-field specifies something about the custom item, thus:
description=My custom item|price=12.34Now, in my particular case, I was encapsulating an XML feed of products from another site (a parts supplier) so …
ecommerce interchange json
cPanel Exim false positive failure & restart fix
I’m not a big fan of add-on graphical control panels for Linux such as cPanel, Webmin, Ensim, etc. They deviate from the distributor’s standard packages and locations for files, often simultaneously tightening security in various ways and weakening security practically by making several more remotely accessible administration logins.
On one of the few servers we maintain that has cPanel on it, today we did a routine Red Hat Network update and reboot to load the latest RHEL 5 kernel, and all seemed to go well.
However, within a few minutes we started getting emailed reports from the cPanel service monitor saying that the Exim mail server had failed and been restarted. These emails began coming in at roughly 5-minute intervals:
Date: Tue, 24 Jul 2012 14:21:05 -0400
From: cPanel ChkServd Service Monitor <cpanel@[SNIP]>
To: [SNIP]
Subject: exim on [SNIP] status: failed
exim failed @ Tue Jul 24 14:21:04 2012. A restart was attempted automagically.
Service Check Method: [socket connect]
Reason: TCP Transaction Log:
<< 220-[SNIP] ESMTP Exim 4.77 #2 Tue, 24 Jul 2012 14:21:04 -0400
<<
<<
>> EHLO localhost
<< 250-[SNIP] Hello localhost.localdomain …hosting redhat sysadmin