Skip to content

Two Nifty Mechanical Engineering Resources

2013 August 2
by Tedb0t

Today I stumbled across these nifty mechanical engineering resources:

  1. 507 Mechanical Movements,” a wonderful cross between a 19th-century encyclopedia and interactive web resource for all manner of clever mechanisms.
  2. GearSketch, a demo web app and source code for very rapidly modeling gear-based mechanisms.  I’m really impressed with this, and it’s just the beginning—I could see people continuing to extend the code and taking it really far.

On Secrecy & Authority

2013 June 29
by Tedb0t

One week ago, my wife, Lindsey, and I returned home from a fabulous week in Ireland for our honeymoon.  By the time we had landed, Lindsey was suffering from some painful gastritis (she has a very sensitive stomach/GI system) and walking was exacerbating it, so we took advantage of the free wheelchairs being offered right inside the jet bridge.  A very helpful young guy henceforth wheeled Lindsey around the airport. We joked that Lindsey’s red merino wool sweater that we bought in Kenmare adorably exaggerated the “little old lady” look of her in the wheelchair.  We got to the customs booth and presented our passports.  The officer was taking a while with Lindsey’s, so I fiddled around on Instagram on my phone until the officer sternly and sharply instructed me that there is “NO TEXTING” while in the immediate area of the booth (I guess).  Lindsey told me she was still feeling the gastritis pain.  After another couple of minutes I got the impression something was wrong.  They were asking Lindsey if she’d ever notified them of a lost passport. read more…

Strange Loop Talk Online: “Getting Physical”

2013 May 10

I just found out that my talk from the Strange Loop conference last year, “Getting Physical: Networked Hardware with Node.js” is online.  Check it out here!

Sublime Tunnel of Love: How to Edit Remote Files With Sublime Text via an SSH Tunnel

2013 February 4

Eventually you will need to edit a file in-place on a server, for one reason or another (i.e. working on a Javascript front-end that requires templating from a backend); this is partly what Emacs and Vim are for (and they’re both very good at what they do).

There’s nothing wrong with learning either of those tools, but if you really don’t want to, there are options.  If the server is running FTP, you can use something like Transmit to open the file in a local editor and saves will be automatically uploaded to the server.  Unfortunately, FTP is a very old and VERY insecure protocol that should not be used anymore.  What else can we do?

Using Secure Shell (SSH) Tunneling, we can establish an SSH session that routes arbitrary traffic through it to a specified port for any use we want.  Thanks to a nifty set of scripts called rsub, modified originally from TextMate’s rmate, we can run a little utility server on our local machine that interacts with your remote server for you and lets you open up remote files and save them back, all through an encrypted channel.

What Do I Do?

  1. As of writing, these instructions work only for Sublime Text 2.  If I get a chance I’ll look into forking rsub for the newly released ST3 (which runs Python3).
  2. If you don’t already have Sublime Text’s wonderful package manager, install it.
  3. Hit Ctrl+Shift+P, start typing “install” and select “Install Package”
  4. Start typing “rsub” and select it.
  5. Once it’s installed, get on your terminal and do
    nano ~/.ssh/config
  6. Paste the following lines:
    Host your_remote_server.com
        RemoteForward 52698 127.0.0.1:52698
  7. Save (ctrl+w) and SSH into your server (ssh username@your_remote_server.com).
  8. ‘Install’ the rsub remote script:
    sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate
  9. Make that script executable:
    sudo chmod +x /usr/local/bin/rsub
  10. Lastly, run rsub on the remote file you want to edit locally:
    rsub ~/my_project/my_file.html

    and it should magically open in Sublime Text!

Let me know if this works for you! Enjoy!

Updating a Mailchimp mailing list with past EventBrite attendees

2013 January 29
by Tedb0t

At Kitchen Table Coders we use EventBrite to sell tickets and Mailchimp to email fans about new classes.  Every time we do a new class I wanted to update our main mailing list with the new attendee email addresses, so I wrote this simple Python script to do it automatically.  Usage details are in the readme.  Enjoy!

Batch convert files to PDFs in OSX Mountain Lion

2012 December 12
tags: , ,
by Tedb0t

Today I needed to convert a bunch of RTF files (I know, what?) to PDFs.  After stumbling through a bunch of dead ends, I realized this—like most things—could be done incredibly easily in Bash:

#!/bin/bash
for file in *.rtf ; do
filename=$(basename "$file") /usr/sbin/cupsfilter "$file" > "$filename.pdf"
done


Getting Physical: Workshop Notes

2012 September 22

Here are some notes and links for my Strange Loop workshop, “Getting Physical.”

Slides for TimesOpen “Sockets & Streams”

2012 September 13
by Tedb0t

Last night at the New York Times “TimesOpen” event, I gave a presentation on internet-enabled bubble guns, wireless joysticks for browser games, and how the “Internet of Things” is better understood as an Internet Ecology:

Thanks to everyone for coming and to Brad Stenger and everyone at the Times for inviting me!

Arduino: A new & improved Button library with some handy features

2012 August 2
by Tedb0t

By Ted Hayes, from code originally by Alexander Brevig & Tom Igoe

The Arduino Button library (Github Repo) makes it easy to do some very common but rather tedious tasks. Usually when you interact with a button (such as a momentary switch), you mainly want to detect the state change, not just the current state. You have to do something like:

int lastState = 0;
void loop(){
    int currentState = digitalRead(11);
    if(currentState != lastState){
        // do something
    }
    lastState = currentState;
}

It’s not hard, just tedious. This new and improved Button library makes this much simpler but adds so much more. Now you can do it this way:

Button button = Button(12);

void onPress(Button& b){
	Serial.print("onPress: ");
	Serial.println(b.pin);
	// will print out "onPress: 12"
}

void setup(){
  Serial.begin(9600);
  // Assign callback function
  button.pressHandler(onPress);
}

void loop(){
  // update the buttons' internals
  button.process();
}

Features

  • Object-oriented design
    Button myButton(11);
  • Automatic pull-up setting
    Button myButton(11, BUTTON_PULLUP_INTERNAL);
  • Simplified state-change detection:
    if(button.isPressed()) ...
  • Callback model
    button.pressHandler(onPress)
  • Built-in debouncing
    // Sets 50ms debounce duration
    Button button = Button(12, BUTTON_PULLUP_INTERNAL, true, 50);

Installing

To install, download the library, extract it to ~/Documents/Arduino/libraries and rename the folder “Button.” (Github generates a different name for the zip link.) Restart Arduino if it was already open.

I hope you find this useful! Please report any bugs using the Github issue tracker.

Arduino: How to Read and Write EEPROM values

2012 August 1
by Tedb0t

When you reset an Arduino, the state of any variables you might have will be lost. So what if you want to keep a value even after it’s been powered off? Luckily, ATmega chips have an area of memory called EEPROM, or “Electrically Erasable Programmable Read-Only Memory.”  This allows you to store persistent values, and Arduino ships with an EEPROM library that makes it easy to use.

Here’s an example Arduino sketch that demonstrates how to read from and write to this part of memory:

Tutorial: How to use your Raspberry Pi like an Arduino

2012 June 15
by Tedb0t

Finally got to experiment with the Raspberry Pi’s GPIO (General Purpose Input/Output) pins.  I tried three methods: Python, Bash and C, and will describe each.  But first, here’s some setup information. read more…

How to build Pd-extended on the Raspberry Pi

2012 June 14
by Tedb0t

It was quite an ordeal, but I managed to build Pd-extended (Puredata with a bunch of externals) on my Raspberry Pi running Debian Squeeze.  I also uploaded my finished package (.deb) to puredata.info, see below for details.  Here’s what you need to do: read more…

Running Puredata on the Raspberry Pi

2012 June 1
by Tedb0t

I’m thrilled to say that today I succeeded in getting Puredata running on my Raspberry Pi. Here’s how!

First, follow this guide to get your Pi set up for the first time.  Make sure your Pi is connected to the internet, and now we can install Puredata.  We’ll start with Vanilla, since pd-extended is not maintained for ARM (as far as I can tell).  I’ll explore getting pd-extended working in a future post (hopefully very soon).

sudo apt-get update
sudo apt-get install puredata

Easy. What’s not easy is getting sound working. This took me about half the day but here’s what worked:

sudo apt-get install alsa-utils
sudo modprobe snd_bcm2835

Note that the modprobe line needs to be run every time the Pi is booted, so you can add it to an .rc file if you want.  Now connect some speakers, turn them down for safety, and run this to make sure sound works:

sudo aplay /usr/share/sounds/alsa/Front_Center.wav

If it works, good! You can now run a Pd patch like so:

pd -nogui -noadc -alsa testPatch.pd

For convenience, here’s my test patch (testPatch.pd) that outputs an LFO’d sine wave. *Important!* Notice in the patch that the loadbang is delayed by 100ms! This is deliberate to avoid a bug in Pd regarding ALSA.

Please let me know if this worked for you.  Happy hacking!  Next up, I’ll be trying to build Pd-extended and then tackling the Raspberry Pi’s General Purpose I/O.

UPDATE:

You’ll notice that the sound quality out of the 1/8″ jack is messed up in some cases (most in my experience).  I’ve heard from various sources that the R-Pi does not use a “real” DAC (Digital-to-Analog-Converter) and that you should get better sound from a USB adapter or from the HDMI output.  Still following up on this.

Getting Started with the Raspberry Pi

2012 June 1
by Tedb0t

The Raspberry Pi is a very low-cost, very small computer capable of running Linux that also provides GPIO (General Purpose Input/Output).  As such, it’s something of a hacker’s dream and there’s been a ton of buzz around it.  I ordered two a couple of months ago and just got them in.  Here’s what you need to get started. read more…

How to get the signal strength of 2 XBees in Processing

2012 May 24
by Tedb0t

I put together a little sketch here on Github that tells you the RSSI (Received Signal Strength Indicator) of a remote XBee in Processing.  All the instructions are there (and here); check it out and let me know what you think.  Post a comment with what you make! read more…

Solved: Mounting Synology DiskStation SMB Share from Ubuntu

2012 May 22
by Tedb0t

Today I received my brand new Synology DiskStation DS411 NAS and I was eager to start transferring files off my old Ubuntu server onto it.  I immediately ran into a problem with Ubuntu: though my DiskStation showed up in Network > Windows Shares, I got the dreaded “Unable to mount location: Failed to retrieve share list from server” message.  I hacked on this for the next hour and managed to successfully mount my DiskStation shares in Ubuntu. Read on! read more…

How I Got a Tornado App Running on Heroku in 10 Seconds

2012 April 26

I’d been wanting to try out Heroku and Tornado for a while, so why not try them together?  I found a nice starter repo by Mike Dory, co-author of the O’Reilly Tornado book, so I figured I’d use that.  I forked it and rearranged it a bit, and it worked perfectly!  Here’s what I did:

  1. I’m on a brand new computer, so I had to install some basic stuff first:
    1. Setuptools:
      sudo curl http://python-distribute.org/distribute_setup.py | sudo python
    2. PIP:
      sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
  2. Get the starter repo.
  3. Make a Heroku account if you don’t have one and set it up.
  4. Make init-project.sh runnable:
    chmod +x init-project.sh
  5. Run
    ./init-project.sh
  6. That should be it, and your Heroku app is live!

Let me know if this works for y’all!

How to Build clj-processing

2012 March 1
by Tedb0t

Recently I wrote up a tutorial on getting started programming Processing sketches in Clojure. The clj-processing bindings require a slightly involved build process, which I’m detailing here.  I have since created a quick-start project that contains the pre-built binary, so unless you want to build a newer version of the processing.core.jar library, you can use that.  So here’s how to build it. read more…

Getting Started with Clojure & Processing

2012 February 28
by Tedb0t

For the past little while here at the studio, there’s been a lot of buzz and conversation about Clojure, a modern LISP language that runs on the Java Virtual Machine.  It’s a fascinating language that can help anyone learn about functional programming.  There are a variety of interesting resources for learning Clojure, but I find it’s most fun when your code can make something happen on your screen instantly, like Processing does for Java.

As such, my friend Tims Gardner and I were talking about putting together a class on Clojure & Processing using Roland Sadowski’s clj-processing bindings and Arthur Edelstein’s Clooj IDE.  So, to make things as fast and easy as possible for people to get started, I made a Clooj/Processing Starter Project that you can download and start using right away!  Here’s what you need to do. read more…

Kitchen Table Coders in The Atlantic

2012 February 28
by Tedb0t

My studiomates and I do workshops most weekends on various (sometimes esoteric) coding and hacking subjects, and recently The Atlantic ran a story about us on their blog.

Awesome!  For more information on Kitchen Table Coders, check out our website and our EventBrite page.