Python FTW!

some problems, solutions, and other stuff i've encountered as a web developer

Postgresql Leopard Gotchas →

After a fresh postgresql installation, initdb didn’t work until I reset the kern.sysv.shmall and kern.sysv.shmmax:

sudo sysctl -w kern.sysv.shmmax=134217728
sudo sysctl -w kern.sysv.shmall=65536

A Better ri →

Debian Administration: Using GNU Screen  →

  • screen
    • Run a new screen session
  • screen -R
    • Reattach to a previously detatched session
  • Ctrl-a c
    • Create a new window.
  • Ctrl-a k
    • Kill the current window - after confirmation
  • Ctrl-a Ctrl-a
    • Switch to the other window
  • Ctrl-a S
    • Split the current window in two.
  • Ctrl-a TAB
    • Move between split sections of the screen.
  • Ctrl-a A
    • Give the the current window a name.
  • Ctrl-a ”
    • List all windows - move around to change the window with the arrow keys

Using Debugger in a Phusion Passenger Dev setup →

My setup: Rails 2.1.2, Passenger 2.2.1, ruby-debug 0.10.3

app-engine-patch -- ignoring mediagenerator

move the django admin media files from _generated_media/1/admin to some directory inside the PROJECT_DIR:

1. move the admin dir to desired location, say PROJECT_DIR/admin_media

2. modify app.yaml urls to point to that static_dir location, e.g. add

- url: /admin_media

static_dir: admin_media

3. modify the MEDIA_URL and ADMIN_MEDIA_PREFIX in settings.py

MEDIA_URL = “/media/”

ADMIN_MEDIA_PREFIX = “/admin_media/”

We need to override MEDIA_URL so that when we access the media_url path from the templates, we don’t get the altered media_url (settings_post.py alters this by appending the MEDIA_VERSION by interpolating the %s. ADMIN_MEDIA_PREFIX is also based on the MEDIA_URL, but we want it to use /admin_media.

Installed some stuff today

wxpython from http://www.wxpython.org/download.php Unicode py2.5 build

sqlalchemy 0.5.3 via easy_install

phusion passenger 2.2 and nginx (installed via passenger)

All programmers are optimists. Perhaps this modern sorcery especially attracts those who believe in happy endings and fairy godmothers. Perhaps the hundreds of nitty frustrations drive away all but those who habitually focus on the end goal. Perhaps it is merely that computers are young, programmers are younger, and the young are always optimists.

— Frederick Brooks

Content Types in Rails Controllers and RSpec'ing It

From the to_csv plugin README, you can set the content type to text/csv in your rails controller action:

response.headers['Content-Type'] = 'text/csv; charset=iso-8859-1; header=present'
response.headers['Content-Disposition'] = "attachment; filename=users_#{Time.now.strftime("%m-%d-%Y")}.csv"

To RSpec this behavior, this works:

Then "the output should be a CSV" do
  response.headers["type"].should have_text('text/csv')
end

If the cost premium for a more productive developer is less than the higher productivity of that developer, then it’s cheaper to hire the more expensive developer.

— Martin Fowler

Chandler →

A notebook you can organize, back up and share!