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
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?
- 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).
- If you don’t already have Sublime Text’s wonderful package manager, install it.
- Hit Ctrl+Shift+P, start typing “install” and select “Install Package”
- Start typing “rsub” and select it.
- Once it’s installed, get on your terminal and do
nano ~/.ssh/config
- Paste the following lines:
Host your_remote_server.com RemoteForward 52698 127.0.0.1:52698 - Save (ctrl+w) and SSH into your server (ssh username@your_remote_server.com).
- ‘Install’ the rsub remote script:
sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate
- Make that script executable:
sudo chmod +x /usr/local/bin/rsub
- 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!
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!
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
Here are some notes and links for my Strange Loop workshop, “Getting Physical.”
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!
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.
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…
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…
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.
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…
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…
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…
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:
- I’m on a brand new computer, so I had to install some basic stuff first:
- Setuptools:
sudo curl http://python-distribute.org/distribute_setup.py | sudo python
- PIP:
sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
- Get the starter repo.
- Make a Heroku account if you don’t have one and set it up.
- Make init-project.sh runnable:
chmod +x init-project.sh
- Run
./init-project.sh
- That should be it, and your Heroku app is live!
Let me know if this works for y’all!
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…
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…
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.
The New York Society for Research Art presents a gathering of artists, curators, gallerists and theorists to investigate and debate the role of scientific and technological experiment in contemporary art practice—when is an artwork a science project, and when is a science project an artwork? Our guest speakers will present a variety of perspectives on the topic, ranging from historical to curatorial to practical to economical. The talks will be followed by an open panel discussion to address and debate the presented ideas interactively with the audience.
The event is free and open to the public! Register on EventBrite (and please consider a donation!). Also check out the Facebook Event.
Confirmed speakers include:
- Georgia Krantz, Education Manager, Guggenheim
- Kyle McDonald, Artist
- Luther Davis, Artist
- Keynote by Ted Hayes and Alex Dodge, Artists
Presenter Biographies:
Georgia Krantz works full-time as the Education Manager for Adult Interpretive Programs at the Guggenheim Museum. She is an art historian with extensive teaching experience from Ancient to Contemporary Art. She is Adjunct Professor at the New School as well as ITP, and lectures at the Guggenheim, the Museum of Modern Art and the International Center of Photography. Over the past few years she has been involved in several outside projects including an NEA-funded educational website for the Rubin Museum of Himalayan Art, and Vital Visionaries, a study by the National Institute on Aging on the value of art for promoting intergenerational communication. She has an MA in Art History (Northern Renaissance and Baroque Art), and is working on her Ph.D dissertation in Modern Art.
Kyle McDonald works with sounds and codes, exploring translation, contextualization, and similarity. With a background in philosophy and computer science, he strives to integrate intricate processes and structures with accessible, playful realizations that often have a do-it-yourself, open-source aesthetic.
http://kylemcdonald.net/