As you might know I’m a designer and developer, and for the first time in my life i’m thinking about kids. Partly because I’m on the cusp of turning 30, and in a stable relationship, but also because right now I’m babysitting a toddler. He’s really cool, and extremely curious.
In exploring his environment around the home where he lives, there are places and things he manages to get to that are clearly new for him. I had the idea of turning one of those push lights into something more interesting, like make it light up and make a noise, and put them all over your house, encouraging exploration, but in the *right* places. At least, I would since I grew up being uncoordinated, and I’d want my kid to be able to literally be able to crawl up the walls.
What do you think?
So installing Locker can be a bit of a bear, so I put together this howto since my laptop got stolen last week, and I had a brand spanking new macbook pro to try out locker from the very start. With this guide, using OSX, you could install Locker for yourself at this very early stage to try it out.
Start by getting Git
Git is used to get Locker. It’s also used to contribute to locker. Git is great. Go get git.
http://code.google.com/p/git-osx-installer/downloads/list?can=3&q=&sort=-uploaded&colspec=Filename+Summary+Uploaded+Size+DownloadCount
Get XCode (Developer Tools)
Go to the Apple Store, search for “Xcode”, download. This is needed for compiling Node.js. It was $5.00. I remember this being free before the App Store…. >:(
Download Node.js
http://nodejs.org/#download
I grabbed the tgz.
curl -o node.tgz http://nodejs.org/dist/node-v0.4.7.tar.gz
cd node-v0.4.7/
So I read README.md. Looks like the usual drill of ./configure; make; make install.
./configure
make
Some warnings about directory not found for option ‘-Lusr/local/lib’. Hopefully that won’t stop me.
Going to try make test to test to see if it works as the node guys expect node to.
make test
Crap, one of the test failed… “simple/test-http-dns-fail” my node doesn’t ever fail, so this will be irrelevant (j/k).
make install
Eep
Cannot create folder
'/usr/local/include/node/' (original error: [Errno 13] Permission denied: '/usr/local/include')
Lets do that with sudo, if it works for sandwiches…
Yay! ‘install’ finished successfully (0.256s)
Ok, NPM now.
This is for node packages. Yummy yummy nodey packages.
curl -o install_npm.sh http://npmjs.org/install.sh
sudo sh install_npm.sh
Okay, now we can install Locker!
git clone https://github.com/LockerProject/Locker.git
cd Locker
Yay, downloaded (cloned) it directly from github.com. Now I have my own personal Locker platform to run with.
We need to set it up though…
npm install
python setupEnv.py
Okay, nothing fishy there…
node lockerd.js
Hot damn, it’s up! Now to go to http://localhost:8042 to access it with Chrome.
Here’s a picture of a kitty to show you how I feel:


I’m really pleased to announce that Andrew, Anna, and my iPhone Wine App, Fine Local Wine is live on the app store. It’s my first push into real mobile development, and I’m really proud of what we’ve accomplished. This app uses Fine Local Wine‘s website as the backend, and reuses much of Gaia iPhone GPS‘s framework on the mobile frontend.
My aim is to do more development, and rebuild the backend with Pinax to allow more user input into what wineries are in our database, and allow people to rate and review the ones that are.
Would love to hear your feedback. If you leave me a comment I’ll give you a promo code so you can try the app out yourself for free
I’ve been expanding my library recently, and I wanted to share a list of some advanced JavaScript books I’ve picked up:
If you’re totally new, these probably aren’t the best books to dive into, but I still recommend picking up JavaScript: The Good Parts. It’s amazing reading, really gave me a much better understanding of the language, and incredibly dense.

This is in response to Daniel Barreiro’s post on putting DataTables in DataTables:
http://www.yuiblog.com/blog/2010/03/17/using-nested-datatables-for-row-expansion/
Credit: my coworker Jason R. Smith.
I saw a message on twitter about something called JSONPX, and did some research to try to find out what it was. According to Wait till I come this is a new way to provide XML with a callback. Essentially this is a format to provide markup Yahoo’s API with a callback and metadata describing the query.
Pretty slick, if you ask me. Normally I’d take the JSONP results and have a JavaScript templating engine like John Resig’s Micro-Templating. If you use Yahoo’s sanitize function, you can even make the HTML safe to insert via innerHTML, even though innerHTML is evil.
As it gets easier to do HTML layout without markup hacks, I see this approach becoming more common. Get the markup you want, with the metadata you need.
I wanted to use tags with SQLAlchemy, so I looked up previous examples and found Wayne’s post on how he did it. I adapted his code into a single file example so you can see better how it works. For any given page, there can be any number of tags .appended to it. For any given tag, you can .append it to any number of pages.
For example:
page = Page(u"Example Page")
page.append(Tag(u"examples"))
from sqlalchemy import *
from sqlalchemy.orm import *
engine = create_engine('sqlite://')
metadata = MetaData(engine)
#engine.echo =True
page_table = Table("page", metadata,
Column("id", Integer, Sequence('page_seq_id', optional=True), primary_key=True),
Column("name", Unicode(100), nullable=False),
)
tag_table = Table("tag", metadata,
Column("id", Integer, Sequence('taq_seq_id', optional=True), primary_key=True),
Column("name", Unicode(50), nullable=False, unique=True),
)
pagetag_table = Table("pagetag", metadata,
Column("id", Integer, Sequence('pagetag_seq_id', optional=True), primary_key=True),
Column("pageid", Integer, ForeignKey('page.id')),
Column("tagid", Integer, ForeignKey('tag.id')),
)
class Tag(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return "Tag(\"%s\")" % self.name
class Page(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return "Page(\"%s\")" % self.name
mapper(Tag, tag_table)
mapper(Page, page_table, properties = {
'tags':relation(Tag, secondary=pagetag_table, cascade="all"),
# 'tags':relation(Tag, secondary=pagetag_table, cascade="all,delete-orphans"),
})
metadata.create_all()
sess = create_session()
page = Page(u"Tags with SQLAlchemy Example")
page2 = Page(u"Hot New Video Game Consists Solely Of Shooting People Point-Blank In The Face")
page3 = Page(u"Congressman's War Hero Son Would Have Wanted Highway Bill Passed")
tag = Tag(u"examples")
tag2 = Tag(u"onion")
page.tags.append(tag)
page2.tags.append(tag2)
page3.tags.append(tag2)
sess.add(page)
sess.add(page2)
sess.add(page3)
sess.flush()
tag_q = sess.query(Tag)
tags = tag_q.all()
print "Number of tags:", len(tags)
# filter pages by tag(s)
page_q = sess.query(Page)
pages = page_q.join('tags').filter_by(name=u"tag").all()
print
print "First Page"
print page_q.first()
print page_q.first().tags
print
print "Second Page"
print page_q.all()[1]
print page_q.all()[1].tags
print
print "Third Page"
print page_q.all()[2]
print page_q.all()[2].tags
# delete-orphans does the work for us here...
#sess.delete(pages[0]
#sess.flush()
print
print "All tags"
tags = tag_q.all()
print tags, "Count:", len(tags)
print
print "Tag cloud anyone?"
# see the source code linked below for a properly weighted tag cloud.
tag_q = sess.query(func.count("*").label(u"tagcount"), Tag)
tag_r = tag_q.filter(Tag.id==pagetag_table.c.tagid).group_by(Tag.id).all()
#print tag_q
print tag_r
# what about pages with related tags?
page_q = sess.query(Page)
taglist = [u"tag1", u"tag2"]
tagcount = len(taglist)
page_q.join(Page.tags).filter(Tag.name.in_(taglist)).\
group_by(Page.id).having(func.count(Page.id) == tagcount).all()
I know tag clouds are passe, but I still think from an information architecture perspective, tags still better than categories.
I’m not religious but I like the idea of Lent because it fits into the idea of changing our habits, which is hard to do and potentially has dramatic long standing effects on how we live.
I for one love reading Reddit and sometimes Digg, but I find it to be somewhat a sinkhole. Sure it’s funny to read about how someone destroyed their finger with magnets or see a cute picture of a coyote on the BART, but from a learning perspective, I’d be better off spending my time on hacker news.
So to that end, I’m modifying my host file to give up reddit for lent. Who knows, maybe instead of removing the entry after lent, I’ll add more instead.
So you want to find out why your Pylons app is running slowly? Well most likely it has to do with your SQL queries, and the best way to see what’s going on and how long each request is taking is to install Dozer (by benbangert of Pylons), and load it up with a TimerProxy (by zzzeek of SQLAlchemy).
Sound like fun? Well, here’s how to do it.
Install Dozer:
sudo easy_install -U http://www.bitbucket.org/bbangert/dozer/get/b748d3e1cc87.gz
Add this to your middleware:
# Add this to your middleware.py, right before return app
if asbool(config['debug']):
from dozer import Logview
app = Logview(app, config)
Add this to your development.ini
# Add to development.ini logview.sqlalchemy = #faa logview.pylons.templating = #bfb
(you can customize the colors here)
Next, modify your configuration ini as well as you like to configure what shows up in the log. Note that I have root set to INFO which will squelch a lot of messages. Change this to DEBUG to see more of what’s going on in each request.
# Logging configuration [loggers] keys = root, YOURPROJ [handlers] keys = console [formatters] keys = generic [logger_root] level = INFO handlers = console [logger_YOURPROJ] level = DEBUG handlers = qualname = YOURPROJ.lib [logger_sqlalchemy] level = INFO handlers = qualname = sqlalchemy.engine [handler_console] class = StreamHandler args = (sys.stderr,) level = NOTSET formatter = generic [formatter_generic] format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s datefmt = %H:%M:%S
Add this file to /lib/
querytimer.py
from sqlalchemy.interfaces import ConnectionProxy
import time
import logging
log = logging.getLogger(__name__)
class TimerProxy(ConnectionProxy):
def cursor_execute(self, execute, cursor, statement, parameters, context, executemany):
now = time.time()
try:
return execute(cursor, statement, parameters, context)
finally:
total = time.time() - now
log.debug("Query: %s" % statement)
log.debug("Total Time: %f" % total)
Okay, one last thing, modify your SQLAlchemy engine in environment.py to this:
engine = engine_from_config(config, 'sqlalchemy.', proxy=TimerProxy())
and add an import at the top:
from YOURPROJ.lib.querytimer import TimerProxy
So that’s it! Restart paster, and load up a request in your web browser. There will now be a bar at the top that you can click on and see all the requests.
If you want to run TimerProxy on it’s own (that is without Pylons and Dozer, see zzzeek’s post on “Timing All Queries“.