Friday, April 6, 2012

Compiling (for Go) github.com/gwenn/gosqlite

In case you received a compilation error (for example, when fetching the package with `go get`) indicating that the symbol sqlite3_table_column_metadata could not be found, then you're likely linking against a sqlite build that does not implement the full C API that gosqlite is expecting.

(the rest of this guide assumes a Unix-like environment)

One solution would involve stamping out meta.go, and everything that may rely on it.

A most likely simpler solution involves locally building sqlite to include this functionality. To do this in a minimum number of steps, download the 'sqlite-autoconf' tarball from , unpack it, and run:

`CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA" ./configure`

At this point, the typical `make && make install` process should work as expected to produce the needed library. Since this build of sqlite probably ended up in /usr/local, you'll, at a minimum, need to set cgo's linker environment variable:

`export CGO_LDFLAGS="-L/usr/local/lib -lsqlite3"`

After doing so, rerun the `go get` or `go install` command that had previously failed: hopefully it will now build without error.

Saturday, March 26, 2011

Cleaner pseudo-randomized views in CouchDB

Lately I've been running into several explanations on how to efficiently get random documents out a Couch database, and so far, the majority of the approaches settle on storing a random value in the document itself, as demonstrated here. This seems like a waste (it adds administrative clutter to the document).

Of course, it's an understandable approach, since couch view functions are required to be idempotent (running the same function with the same input must produce the same output), and at face value, you'd think that generating a random number in the view function would produce different results each time, even with the same input. However, that's not necessarily the case.

Using closures to optimize speed of couchdb-python view functions

Python's standard library (and 3rd party modules) brings a lot of pluggable functionality that you can use in Couch view (map/reduce) and list/show functions.

Here, we'll using the couchdb-python library, which is, to my knowledge, the only well known couchdb library for Python that implements a view server (couchdbkit does not, which makes it fall out of consideration for the things I commonly need to do).

Wednesday, January 12, 2011

Mapnificent

Just came across Mapnificent, a service on top of Google Maps to aid in using public transit to get around.  It's exceptionally easy to use and quite intuitive, and to say the least, after 30 seconds I was already impressed with its ability to display the estimated area that you can cover within a given amount of time using a configurable combination of public transit, walking, and biking.


Plotting 15 minute reachability zones from two separate locations in night mode.


Laticauda colubrina

Photo by Jens Petersen
The Colubrine sea krait has got to be one of interesting aquatic species of animal, from my perspective.  The Laticauda genus is one of the few, if only, among the sea snake family, to have any species retaining adaptations for both aquatic and terrestrial activity, and as evidenced by the photo, right, is putting on a top-notch marketing campaign.
Various species within the family are known to or thought to possess social behaviors (including swimming alongside certain fish species), the ability to remain submerged for hours (they must surface to respire), are often highly venomous (much more so than terrestrial snakes), yet almost all species docile towards humans.  Many of these species have convergently evolved the ability to breathe in a limited fashion through their skin, which is a trait most famously found in amphibians.
L. colubrina is certainly an excellent example of how morphological and physiological traits otherwise found fish, amphibians, and various mammals can, by means of independent evolution, result in the creature we see today.