postgres gem on ubuntu

Posted by Dick on May 02, 2007

Ubuntu put their postgresql client bits where gems can’t see them.

Google turned up the answer in the past, but today I had to figure it out myself.
So for the next time, here’s how to get the client bits needed for a gem build.

planb $ sudo apt-get install  postgresql-client-8.2 libpq-dev
planb $ sudo gem install postgres -- \
--with-pgsql-include-dir=/usr/include/postgresql \
--with-pgsql-lib-dir=/usr/lib/postgresql

Rails (well, rake) calls out to dropdb and createdb to flush the test database. If you want to do TDD, make sure the rails DB user has ‘createdb’ rights and owns the 3 databases:

postgres@elephantom $ createuser -PREdS railsguy
postgres@elephantom $ createdb -O railsguy live
postgres@elephantom $ createdb -O railsguy dev
postgres@elephantom $ createdb -O railsguy test

dropdb/createdb need access to the ‘postgres’ database to operate. Until you know this,
errors like

FATAL: no pg_hba.conf entry for host “1.2.3.4”, user “railsguy”, database “postgres”, SSL off

will have you staring at database.yml until your eyes cross.

you might as well have a pg_hba.conf line like

#TYPE  DB   USER       CIDR         METHOD
host   all   railsguy    1.2.3.4/32   md5

and have done.

a different DRM

Posted by Dick on October 16, 2006

I finally snuck Rails under the radar at work (in an unholy union with mod_perl – it’s been interesting) and needed to get up to date quickly. Thought I’d go for the AWDWROR Beta Book -
passed on the Book + PDF combo for a few reasons

  1. I fancied saving a few trees
  2. it was a lot cheaper (no shipping)
  3. the book isn’t ready yet, so in the short term it made no odds

The beta book idea is fantastic.

The PDF cost about 12 quid at the end of August (buy stuff from the States whereever possible – the dollar is doing really badly against the pound at the moment).

Since then I’ve had free updates – sometimes sections are rewritten, sometimes whole chapters.
The sections that differ from the first edition are highlighted, so it’s easy to find new material.

PDF books, as you probably know, are great. You click the table of contents or index to get to relevant sections. It’s searchable. You can cut n paste it. When you’re working through the code examples, you click a URL and your browser grabs the CSS or ruby code.

More importantly, they haven’t gone out of their way to piss me off.

DRM done wrong

I’ve had an Audible account since they gave out free ipod shuffles to subscribers last year. They have a good range of books, and you can get 40-odd hours of Bill Bryson or Marco Polo for about 12 quid. Their customer service is the best I’ve ever encountered.

The only thing wrong with them is the file format. I need to give a username and password to burn it to CDs. If I want to listen to it on my phones MP3 player, I have to burn it to CD, then rip it back to MP3.

Bear in mind I can get these books on P2P for nothing. I actually pay them to fuck me about like this.

DRM done right

The Beta Book copy protection system works like this.
You’re allowed as many copies as you feel you need to keep it safe (though if it get destroyed, you just ask for another). It’ll ‘play’ on your phone/ebook reader/laptop/printer/speech synthesizer.

At the bottom of each page, it says “this book belongs to XXX’.

Nothing stops you sharing it, you’ll just look like a bit of a prick (I suspect Dave and co. wouldn’t be too keen to give you any more updates).

I know some hipp people say ‘information wants to be free’. But it’s the information in a book that’s valuable, not the paper it’s printed on.

I have no problem paying for valuable things, but most DRMed products expect you to pay extra for an intentionally broken product.

It’s nice just for once (correct me if you can, but I know of no other examples) to see someone charge less for something that cost less to make.

typo 2.6.0 -> 4.0.3

Posted by Dick on August 11, 2006

Now that the dust has settled a little , I thought it was time to upgrade the blog to 4.0.x.

I was running typo 2.6.0 with rails frozen at 1.0.0 , so to be honest I was expecting trouble. WEBrick ran so fast on my dummy run I thought it was worth the risk.

If you’re thinking of trying it yourself:

CYA

  • backup everything, including the database
  • switch your typo theme back to ‘azure’

The last one saves you a lot of hassle if you’re using a ‘tweaked’ theme – if typo can’t find default.rhtml, it won’t run (it’s not as easy to switch themes from the console as it used to be, as the Settings model has been replaced).

fitter, happier

  • download and extract the typo tarball (gems on textdrive are a pain in the arse.) – this includes rails 1.1.6 in vendor1/.
  • copy over your existing config/database.yml
  • migrate the database
 rasputnik typo-4.0.2 $ RAILS_ENV=production rake migrate

Watch it Just Work (it does on postgresql, anyway),
start it up and have a poke around.

start chopping

On Textdrive, they recently enforced resource limits. After a minute or two I started getting 500 errors as the fcgi backends bloated up and were killed off.
Luckily I’d been warned about this.

 rasputnik typo/ $ cd components/plugins/sidebars
 rasputnik sidebars $ ls
 aimpresence               delicious_controller.rb    tada
 aimpresence_controller.rb flickr                      tada_controller.rb
 amazon                    flickr_controller.rb        tag
 amazon_controller.rb      fortythree                 tag_controller.rb
 ...
 ...
 ...
 rasputnik sidebars $ rm -r forty* backpack* amazon* upcoming*
 rasputnik sidebars $ # restart typo
 rasputnik sidebars $ killall -9 ruby && ~/bin/spawn-typo.sh

That should save you a few Mb. I’ve still had the preview pane crash once while I was writing this, but otherwise it seems a lot happier.

UPDATE – crash bang wallop

Well it’s been a month, and it’s finally stablized. Make sure to do the extra steps here (mainly removing Sparklines) if you’re resource restricted.

1 actually, it doesn’t. Looks like someone dropped a bollock (run ‘rake rails:freeze:gems’ if you want to lock it down).

and she blew, blew, blew, blew, blew

Posted by Dick on October 26, 2005

In other news, The Queen of Changes has decided to punish my arrogance by bumping rails to 0.14.2 on textdrive.
If you get

undefined method `zero?' for true:TrueClass

on publishing, change
app/views/admin/content/show.rhtml:15 :

:s/@article.published.zero?/@article.published?/

which looks to me like something low level changed – either rails or ARs mysql adapter.
This time I checked trac properly and found it wasn’t just me .

Less trivially, Rails 0.14.1 b0rked live search on typo 2.5.6 – patchage has been almost instant, but sadly for trunk only.

I was wary of going to svn when I don’t control the version of the webapp database/webapp framework/OS/webserver it runs on.
But since Rails hasn’t solidified yet, you can’t be suprised at the occasional need to be able to tweak apps as it shifts underfoot.
With gems, you can always tie to a particular version if needed.

So anyway, if the blog suddenly vanishes you’ll know why.

blink and you’ll miss it

Posted by Dick on September 21, 2005

Rubyland continues to expand at ludicrous speed. Today I found out:

I like apt and gems. I like beer and ice cream too. But mixing the two makes me queasy. I’ll wait for the dust to settle.

Now would probably be Haskell time, right?
Trouble is, I actually started my Rails book today – I’m enjoying picking through the typo source so it might be more useful.

This is the trouble with being a self-taught geek.
If only I didn’t have the attention span of a goldf – Cool! ’Incy Wincy Quincy, the Spider Detective’ is back on the radio!