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".
At the most basic level, a graph can communicate key information, like a company's P&L, the median price of a house, or daily average rainfall for a county over a year, but when used effectively, a graph can tell a story.
Much like the rings on a tree can tell you the story of their lives, this graph from the NYTimes, tells the all too true story that we're living right now, every one of us -- the economy. How it varies from the LA Times dead tree edition though is dramatic because it interactively allows you to explore how this bear market relates to the bear markets of our parents, grandparents, and great grandparents.
The NYTimes effectively use a timeline that slides to specific bear markets, making it incredibly easy to see the differences between today and the history that led up to this crisis. Having closely watched the markets, this paints an entirely new picture, however grim it may be.
I'm putting together a costume for Burning Man. It's all around the theme of the American Dream, gone horribly horribly wrong. The truth of the world today is just as sinister, just not so visually repulsive.
Here are the main pieces of the costume. I have yet to get them, so I haven't been able to assemble it yet. They will be modified somewhat to look more "official", possibly incorporating a government looking seal.

EyeClops Nightvision Mask ($80)




Respirator, Coveralls, Chemical Apron, and 28" Chemical Gloves, all totaling approximately $65.
These parts combined with a pair of black boots will create a look that will cover up the entire body, leaving no sense of humanity beyond the humanoid shape, much like HalfLife 2's Combine Soldiers. Combined with some audio on loop possibly similar to 1984 - War is Peace, Freedom is Slavery, Ignorance is Strength, or possibly more aptly, incorrectly telling people they do not have the right to take photographs and to report suspicious behavior immediately.
Maybe this isn't the Burning Man many know and love. It's dark. It's dystopian. It is performance art designed to provoke thought, not laughter or smiles. Is it my dream? No, but I am tired of the security theater and crumbling of civil liberties that is the reality of today's world.
The OpenView Project is a open source, creative commons project for building and taking interactive panoramas much like Google Street View, but of more interesting places than streets, such as farmers markets, concerts, art festivals, and hiking trails, just to name a few. I'm blogging my work on it at OpenView Project (openviewproject.org). I'm very thrilled to be working with photography again, and excited about the prospect of giving people a new pespective of the world around them.