Connecting to the Real World

Comments Off

Yesterday I spent the afternoon at NYC Resistor making my own Arduino (technically a Freeduino) microcontroller.  Say what?  That basically means that I spent the day soldering together a bunch of pieces of electronics that let me connect my computer to the physical world.

Here’s what the darn thing looks like:

Arduino board

The best way to look at this board is to look at the narrow black slits at the bottom and the top on the right hand side: they’re pins that you can connect to external electronic components (e.g., lights, sensors, etc.).  The big black chip controls the signals to those ’slits’ and ultimately connects to your computer via the silver piece on the upper left; you can alternatively plug the board right into the wall via the lower left.

The board itself will not do too much: it has four LEDs and you can blink one of them to make sure it’s working:

Blinking Arudino

I’m going to play around with this some more and if I create anything interesting I’ll put some photos up.

Timestamps in Django

Comments Off

I’ve recently been playing around with the Django web framework (all non-techies should stop reading this at once).  Here’s a little snippet of code that’s useful if you want to add a timestamp to a model you’re creating:

from datetime import datetime

class My_Model(models.Model):
  date_created = models.DateTimeField()
  date_modified = models.DateTimeField()

  def save(self):
    if self.date_created == None:
      self.date_created = datetime.now()
    self.date_modified = datetime.now()
    super(My_Model, self).save()

What happens is that when you save the object, you override the Django save method with your own. It checks to see if the object has a date_created timestamp. If it doesn’t (i.e., you’re creating it for the first time), it adds one. It also updates the date_modified timestamp every time you save it.

You might be wondering: why not just set the model to look like this:

date_created = models.DateTimeField(default=datetime.now())

It won’t work due to a quirk in Python. Python will calculate “now” to be the time when the model is loaded into interpreted. This means that every single object, until you restart the server, will get exactly the same timestamp. Not too useful – so use this hack instead.

The Future of the Web

Comments Off

It’s pretty much impossible to predict the future – particularly for something as fast moving as the Internet.  However, as part of Mozilla’s Concept Series, Adaptive Path has created a few videos (bonus: watch ‘em in HD) on what the future of the browser might be.

Essentially, the browser is the web – and your computer.  Everything is happening in the cloud and the browser is the container for all applications (whether communication, search, etc.) to occur.  One of the interesting aspects is that it involves web services seamlessly transferring data from one to another.

This has been the holy grail for folks for years, but it continually seems to get blocked (mainly due to a lack of standards or a proliferation of competing standards by large incumbents with entrenched interests).  However, it’s starting to occur.

Here’s an interesting example.  I work at WebMD and we have a partnership with Yahoo to serve you ads on Yahoo properties based upon your browsing history at WebMD.  This means that we share our data with them (although they don’t actually know what you saw; they just receive the ad).  Recently, I was testing out WebMD’s Rheumatoid Arthritis (RA) Health Check – and when I went to Yahoo News, check out the ad on the right hand side:

This is just a baby step, but I’m looking forward to the day when web services are constantly sharing data.  Things are going to get very interesting.  Hopefully it won’t create Skynet.