Tuesday, May 31, 2011

Text search, sqlite bindings and Python

c.execute("SELECT * FROM entries WHERE (title LIKE ? OR body LIKE ?) order by date desc", ("%%%s%%" %text, "%%%s%%" %text))

Notes
  1. Putting %?% does not work
  2. "%?%" does not work
  3. Double percent sign (%%) due to python string substitution rules

Saturday, May 28, 2011

Standalone browser based app

Perhaps my long search for a convenient way to code database frontends that work locally ("desktop app") but leverage the power of a browser as a GUI has come to a successful point. This point involves:
  1. Python (Naturally)
  2. Bottle - a "microframework"
  3. py2app - py2exe for windows
The only tricks making Bottle and  py2app work well together were
  1. You need to explicitly list the template files when calling py2app, otherwise they don't get included in Resources
  2. I had to add a url route (which I called /quit) that called os._exit() to shut down the server (otherwise done using CTRL-C). just exit() and even SIGINT did not work. This is a bit extreme, but I think safe in this usage.
I was happy to see that the created app used the Resources directory as the working directory and the packager put all the files in this directory making things very transparent and worry free.

GET or POST?

From the HTML standards.
Use POST when the operation has lasting changes on the world, like a database modification.

Friday, May 27, 2011

Sunday, May 15, 2011

3d wall decor

So, there are artists who paint patterns on walls that turn into a recognizable figure if you are standing at the right perspective (e.g. here).

One easy way to generate these patterns is to set up a projector with a slide of the pattern that you want projecting from the vantage point you want, and then paint according to the projected pattern.

Sunday, May 1, 2011

Nikon D40 (almost) 2 years on

The D40 is an awesome camera, especially at the price I bought it ($375 with kit lens - but refurbished). It's years out of production now and has been superseded, but it does fine for my casual needs. The only two gripes I have about it, in order of importance are:

  1. Auto white balance is sucky for incandescent lighting. So I always switch from auto to preset when I shoot indoors.
  2. Only one func button makes it awkward. I have to pick between select ISO and select WB for that button. I think select WB wins out, but it would be nice to have dedicated buttons for that.

Nikon 35mm f/1.8 AF-S One year on

This lens is very, very good. I had read on boards from people who would never take this lens off the camera. I find that most of my shooting is done with this lens. The kit lens that came with the D40 (The Nikon 18-55 mm) is very good, but the 35mm's 1.8 aperture is great.