Email to Youtube downloader, Redis, Cocoa and OpenGL, Python’s HTTP Requests Module

We rung in the new year with a series of lightning talks:

Stan Schwertly kicked off the presentations with a set of slides on an email-to-youtube downloader script that combined Postfix, bash, and cclive to allow a user to email an address with a list of videos to download. The user receives a response email with a list of direct download links to the videos requested.

Trevor Parker continued the talks by overviewing Redis, a key-value store system that provides several NoSQL-like options for multiple languages.

Tim Heckman followed up with a presentation on Python’s HTTP requests module. The HTTP requests module is a more pythonic version of the current standard library and allows for easier interaction with remote servers.

Brian O’Keefe ended the meeting by discussing CocoaOpenGL, and GLKit for the iPhone. He also went over the pros and cons of component-based game design versus traditional game design paradigms.

Cheers to the Dead Coder Society!

Twilio, Debian Packaging, Community Driven Radio, Pastebin Messaging, Python sh module, and more

The Dead Coder Society had its first meeting with our newest members. This meeting’s content was provided solely by the new members.

Peter Sandin was up first with his Debian Packaging presentation. He overviewed the process of packaging software in Debian and the various ways it can be done.

Tim Heckman followed Pete with two presentations. He discussed using Twilio, Python’s Flask web framework, and Python’s Paramiko library to interact with his network remotely from his cell phone. He also went over his IRC-related project to use Twilio to inform him of chat lines that interest him from irssi.

Nick Pegg continued the presentations by going over NickFM, a community-driven web radio project he has been working on. He combined Icecast, MPD, and custom Python code in order to create a digital station that allows for multiple remote DJs. Dead Coder Society member Brian O’Keefe posted a series on using Icecast for projects in the past as well:

Trevor Parker presented his idea of a pastebin-based system for decentralized, encrypted, and persistent message storing.

Les Aker brought the talks to a close with a presentation on Python’s sh module, which allows for system commands to be run in a pythonic fashion. The sh module integrates nicely with his soon-to-be finished automatic deployment system, Archer.

Cheers to the Dead Coder Society!


Welcoming Five New DCS Members

The Dead Coder Society is proud to welcome five new members:

  • Les Aker
  • Tim Heckman
  • Trevor Parker
  • Nick Pegg
  • Peter Sandin

We’re looking forward to their perspective and new presentations.

Cheers to Dead Coder Society!

Using IRC to set Reminders with the “at” Command


Remind me at 5pm to go to the bank

You can use IRC to remind you to do anything. Now that you have a directory that your IRC bot reads, you can use one of Linux’s best kept secrets: the at command. The at command allows you to schedule one-time jobs to be run in the future — a non-reoccurring cronjob. The real win with using at is its time syntax. Here’s a few examples from the man page:

  • to run a job at 4pm three days from now, you would do at 4pm + 3 day
  • to run a job at 10:00am on July 31, you would do at 10am Jul 31
  • to run a job at 1am tomorrow, you would do at 1am tomorrow.

You can use this to run any command or script at a given time. This makes the at command perfect for usage over IRC — we just need to drop a file with the reminder in the /say directory at the given time. It’s easy to wrap some of this syntax to give the reminder command a human-like syntax.


I went with the following syntax, best expressed with a summarized version of the regular expression used to parse it:

 ^(remind|pm) (me|us|everyone) (at|in|on) (.*?) to (.*)$

You might say the following things in the IRC channel to the bot:

  • remind me in 5 minutes to check the dryer
  • pm me at 10pm to remember to charge my cell phone
  • remind everyone on august 1s to enjoy the weather

These commands all get sent to at. Behind the scenes, the bot does the following:

  1. creates a file under /var/tmp with the contents of the reminder. The filename follows the format mentioned in the Mixing the Command-Line and IRC post, and sets the unique identifier to a hash of the submitter’s nick and current timestamp.
  2. the at command is instructed to move the file from /var/tmp/ to the ~/say directory at the requested time
  3. at the requested time, at moves the file and the bot picks it up and prints it to the channel.

There’s only a small amount of additional wrapping needed to make the interaction fluid. The biggest abstraction is in the difference between the “remind me at/on” and “remind me in” commands. “remind me at/on” passes the date straight through to the at command, where “in” prepends “now +” to the request. That’s it!

The channel has been using the reminder feature more and more. It’s nice to set a reminder with a long article you’d like to read, or set a reminder in 2 weeks to write a blog post for the DeadCoderSociety. Socializing reminders is a great way to increase community interaction and raise awareness for interesting information that might otherwise end up on a sticky note in a pocket somewhere.


The other Friday I was talking about payday and one guy had added a reminder to “GET PAID” for the next set of pairs of weeks. We ended up adding this on the command-line:

for i in `seq 12 2 50`; do
    echo 'echo "GET PAID" > /srv/git/neilforobot/say/#dcs@paid' | 
    at now + $i weeks ; 

At makes setting these types of reminders up easy!

Mixing the Command-Line and IRC bots


Making cookies with IRC and the command-line

My IRC bot checks a directory every minute for files and reads the contents into a channel. This simple feature is also one of my favorites.

The loop:

  1. Checks for the presence of files under /say.
  2. Reads the contents of the file into a string.
  3. Prints the contents into a channel (pulled from filename).
  4. Removes the file.

Mix crontab into this and you can use any of your favorite commandline tools. Here’s a few examples from my own usage:

Finance tip at 8AM every day:

00 08 * * * curl -sLk -o ~/say/#finance@tip

This just hits a PHP script that returns a random money tip. Note: The @ sign is being used to separate the name of the channel and a unique identifier for the file. Multiple files can land in the directory without one overwriting the other.

Top HackerNews link at 1PM:

00 13 * * * ~/cronjobs/ > ~/say/#dcs@hn

Note: The original job was a one liner using Mojolicious:

perl -Mojo -E 'say g("")->dom->at("tr > td.title > a")->tree->[2]->{href}'

It’s been expanded since to include the title and keep the crontab clean.

One-off website update checker:

* * * * * curl -s | diff file1 -
|| echo 'The page changed!' > ~/say/msg@stan_theman@update

This is a quick cheap way of being automatically alerted to changes on a website.

Note: You could easily toss this into a shell script and do some more work to update the file being diffed. This would let you know about continued changes. The current script will ping you until you remove the cronjob in this state. You also need to curl the page into file1 before installing the script — I said it was cheap!

You can use this for any short piece of information (RSS feed updates, system mail, CPU/disk usage). I’ll continue with my other favorite use for this in the next blog post.