Thursday, November 1, 2012

Working with Fusion Tables, and Chrome Extensions

Firstly, Google Fusion Tables v1.0 is simply great.  This post is an attempt to put into tutorial form the presentation that I gave at the Google Developers Group - Twin Cities on November 1st, 2012.

My general outline is to have you
  1. Using a sample csv dataset
  2. upload that into Fusion Table, geocode it.
  3. Practice viewing the data on a fusion table map.
  4. Explore the Fusion Table SQL.
  5. Create a javascript html page the can query the fusion table data
  6. Create a simple Chrome Plugin
  7. Have the plugin query the fusion table data.

 Google Fusion Tables

The primary location for documentation and references is https://developers.google.com/fusiontables/

1 - Using a sample csv dataset

Starting with a simple example.  Let's map all the White Castles in MN, ( as scraped by loving hands from http://www.whitecastle.com/locations/all) Download the MNWhiteCastle CSV file here.. (open and save as or right click and save destination, you know the drill).

2 - upload that into Fusion Table, geocode it.

In your Google drive folder, create a new document, choose More, then Fusion Tables.

Follow the steps and upload the CSV.  Change the name if you like, don't worry too much about other settings, they should be good.  You should now have a Fusion Table that looks like 
The Address column is already highlighted because it recognizes it as an Address Type field.  Since it saw it was an address field, a Map of Address tab was also created.  Go ahead and click there.  It will geocode the addresses and display a map.  YAY.  You mapped a bunch of addresses.  If you chance you table structure you can go to File -> Geocode and it will geocode new addresses.

3 - AGAIN WITH MORE DATA

  1. FriendFace dataset
  2. This time the data is already geocoded, but labeled differently.  You have to specify the lat lon as the address.
    1. Go to Edit->Change column
    2. Change lat to type = location, make it a two column field, and make the two columns lat and lon.
Add a tab to the Fusion Table of a "Map".  You should now see your data points.  BAM!  Like that you mapped 1000 points.  Nice work!

4 - Explore the Fusion Table SQL.

https://developers.google.com/fusiontables/docs/v1/sql-reference has a good description of what you can do with your FusionTable data now that it is up there.  First, set the permissions of your table so that it is viewable to anyone with the link.

Make a note of the docid of your table.  


Now select all rows.  SELECT * FROM DOCID

https://www.googleapis.com/fusiontables/v1/query?sql=
SELECT * FROM 1t3pUD-6Nt2i9tCZpSC_gi3-H0AL1tpO5TGAsCLw

huh.  Pretty quickly I hit a limit.  So tacking on your API Key helps.  Get that from

https://code.google.com/apis/console


https://www.googleapis.com/fusiontables/v1/query?sql=SELECT * FROM 1t3pUD-6Nt2i9tCZpSC_gi3-H0AL1tpO5TGAsCLw&key=<>

Note, the response is JSON, in the order it is in the table.

So.... Check this out you can do spacial operations on the query.  Like say show me the 10 white castles closest to Leal Tillman (44.884779,-93.000282).  We need some tools

  1. Fusion Tables distance function: ST_DISTANCE(<>,<>)
  2. Define a point: LATLON(44.884779,-93.000282), in Lael's case.
so:   
SELECT * 
  FROM [table] 
 ORDER BY ST_DISTANCE(Address,LATLNG(44.884779,-93.000282))



5 - Create a javascript html page the can query the fusion table data

Let's play with Intersect, like on this example: Fusion Tables Layer Example: Intersects Radius
  1. Copy the HTML from the above link.  Save it somewhere locally.  I called it circle.html
  2. It won't work because you need the css.  It's here.
  3. update the  circle.html file.
    1. Line23.  Chance the css to be
      default.css" rel="stylesheet" type="text/css">

  • Also update the tableid to your table. (line 28)
  • Update all lat,lon points from Mountain View to Minneapolis.
    37.4, -122.1
    to
    44.988265,-93.259191     (Code42's office)
    YOU SHOULD FIND 4 

  • NOW load the page.

    TAHDAH......

    Note: when you change the select box, the radius updates and re-queries the data.

    Tuesday, November 1, 2011

    NaMaSoEvDaOfNo once again.

    Another year of trying to wake this mostly dormant blog durring my fit of National Make Something Every Day Of November challenge.

    I had the last evening of my fly tying class tonight.  This summer I took up fly fishing and I have really been enjoying it.  It has taken me some time to figure out what is so contradictary about it, in a way that I love, but still contradictory.  As I mull it over it is very similar to how I think of the Japanese Tea Ceremony.  Or at least the little understanding I have living in this midwestern japophile culture that is otherwise known as Mingeisota.  With fly fishing there is an obsessive love of the simplicity of the task.  The romantic idea of standing in a pristine mountain stream with a box of lures the size of a cigarette box, a rod and maybe a net is the pinacle of simplicity, connectedness, engagement with the activity and natural world around you.  Contrast that with the obsession of objects and the staggering amount people will spend to get the authentically simple experience and you have a sense of the similarities with fly fishing and the tea ceremony.

    You can get started fly fishing for minimal amount of money, but the expense curve is steep in this sport.  You quickly go from $100+ to $1000+ and then think longingly of the next $400 thing that will help make the experience better.  I am still way down on the front end of that expense curve, but enjoying learning the differences between an entry level tool and one that really makes a nice difference in the experience.

    One aspect that I am particularly enjoying about learning fly tying is the atomic nature of it.  I have rebuilt my house from the inside out.  Moved stairwells, reframed the roof, done fine woodworking and finishing of trim, and frankly am a little burned out on it.  For a large part because nothing is a simple project.  I love the finished product, but the reality of having little kids in the house is that I cannot leave my sliding compound miter saw out in the living room for very long.  And bedtime is absolute.  So the idea of starting a fly, finishing it 5-25 minutes later, admiring it, and moving on is very satisfying to me right now.







    Wednesday, July 6, 2011

    My Deploy Script

    Being a development shop often of just 1, I found myself going through many of the same steps to deploy my site to production. Every time I would send it to production, I would think "This should be automated". Over time, I automated a couple step, with human interaction at steps that would require checking for failure, or certain things that would not be easily automated. The more I worked with the deploy script the more I refined the process until now I have a script that allows me to double-click, enter a comment for the subversion update, and then everything else, including error checking, is automated.





    This process goes through all the following steps:
    1. Subversion Checkin / Checkout / Export
    2. ASP.NET 4 site precompile.
    3. If compile fails, abort script
    4. Map to netowork drive on production server.
    5. Zip compiled application with unique name onto production server.
    6. Copy a version to the network for archival purposes
    7. Notify the production server of new app.
    8. Production server unzips new app, deletes old, replaces old with new via file move (less than a second of "downtime")
    9. Send noficiation tweet to @cledwyn that the process has happened.

    This requires having a "Scheduled Task" on the production server.


    Tools that you will need to get this working.

    • Yes this is for a windows environment.  All scripts could be adapted for Mac/Linux....
    • Visual Studio 2010 is helpful
    • Tweepy:  A great python command line tool for posting to twitter.
    • Tortoise SVN.  Invaluable subversion tool.
    • 7za: Command Line version of 7Zip.

    Wednesday, June 15, 2011

    Multiple Columns in Notepad ++

    For many users this is old had, but it is such a nicely implented and handy tool, it speaks to the quality of the wonderfully flexible, high quality, and free tool Notepad ++.

    To select and edit multiple columns in Notepad ++, simply use Shift+Click.  Like so:


    so Slick

    Tuesday, November 30, 2010

    Eye-Fi camera cards

    A year or so ago I purchased a card for my digital camera from http://www.eye.fi/.  This simple little card makes me happy at least once a week.  It's genius: it is wifi aware.  Which means that once you take a picture, it tries to connect to the internet and upload the new pictures.  You can have it save just to your computer, or automatically upload to Flckr, Picasa, or a number of other sites.

    Here is my happy use case.  Often while at work, I'll get an email that looks like this:

    Which means that the family at home has been taking pictures, and my day is interrupted by a cute and often candid update of what my fantastic family is up to today.  

    The new cards will also upload videos, which means that I rarely, if ever take my card out of my camera anymore.  

    Overall, this is one technical gadget that makes my life easier and has extremely low friction.  Exactly what a quality item should be.

    Wednesday, November 24, 2010

    Mont Blanc Fountain Pens

    I grew up admiring my father's Montblanc fountain pen, having worked through scores of fountain pens myself I have yet to make the leap. Maybe when I grow up.

    Here is a long soliloquy of an article, with lots of nice pictures.
    http://www.luxist.com/2010/11/16/birth-of-a-montblanc-making-the-worlds-finest-pen-and-why-you-sh/

    Monday, November 15, 2010

    Studio day

    I feel like I'm making good headway.
    IMAG0310
    The kiln is cooling.

    Made a couple more pieces just in case.
    IMAG0311
    Theo even helped with one of those bottles. it was fun.

    There are for or so bowls drying around the studio, this platter form I've been working on, IMAG0312 and a bigger tray IMAG0313.

    Oh, and this guy
    IMAG0314
    showed up at one point.

    I think I may just fit in one more bisque firing before loading up and heading out to the firing with Simon and they guys this weekend.