Monday, December 30, 2013

Enable UART2 On BeagleBone Black for RS232 Cape

  1. Use this script to ensure UART2 is enabled in the device tree:
  2. Enable ttyO1 it in the firmware using this guide (makes the device appear):
  3. Put a paperclip into the RS232 port like in the picture on this page:
  4. echo hello > /dev/ttyO1
  5. cat /dev/ttyO1

Sunday, December 29, 2013

Clustering With Leaflet

The Z Layout

I'm definitely going to use this technique on my next business site:

Two Column Match - Flask + HandsOnTable

I'm getting more comfortable with Flask, so I decided to experiment with Google App Engine + Flask + HandsOnTable.

Here's the application I made:

It takes the contents of the 2nd column and matches it to the rows of the first column. Just press the "Match" button to see what it does.

I've found myself doing what this application does a few times, but I manually create two python lists and compare them in IDLE. This application streamlines that process quite a bit.

Here's the code:

Thursday, December 26, 2013

SQLalchemy - Simple Select Query

from sqlalchemy import create_engine, MetaData, Table

engine = create_engine('sqlite:///cars.db', echo=False)
metadata = MetaData(bind=engine)

table = Table('cars', metadata)
stmt =
for row in stmt.execute():
    print row

Entity-Attribute-Value - Dynamic Database Columns

This page has a great example of when to use the Entity-Attribute-Value data model:

I'm planning to use it for an application I'm making which has user defined fields.

Wednesday, December 18, 2013

SHOW COLUMNS or Get Column Names From SQLalchemy SELECT Query

Rob Wouter's answer really helped me out:

You can either find the columns by calling result.keys() or you can access them through calling v.keys() inside the for loop.
Here's an example using items():
for v in result:
    for column, value in v.items():
        print('{0}: {1}'.format(column, value))

Wednesday, December 11, 2013

AttributeError: 'dict' object has no attribute '_set_parent_with_dispatch' - SQLalchemy

The documentation says: "Keyword arguments can be specified by specifying the last argument as a dictionary"

So you will need to change this:
__table_args__ = (
{'sqlite_autoincrement': True},
            UniqueConstraint('filename', 'path')

to this:
__table_args__ = (
            UniqueConstraint('filename', 'path'),
            {'sqlite_autoincrement': True}


Flask-Admin Foreign Key Columns Allowing Editing

Make sure you have a row id number as your primary key for your child table. Having a composite primary key didn't seem to save when I was editing the form.

Thursday, December 5, 2013