Monthly Archives: March 2011

A KRL module for StringBin

UPDATE: This module is now listed in the Kynetx module directory. Check it out here.

This morning I wrote my first KRL module. If you remember from February, Sam Curren wrote a Google Calendar module that I used in my own Kynetx app for CS 462. Sam has since written the entire Kynetx Twilio functionality as a module. I’ve had some ideas brewing for modules I’d like to write. So I started today with a really simple one: StringBin.

StringBin is a service that Mike Grace wrote a while ago. It basically lets you store key-values pairs. That’s it. There are two endpoints in the API: read and write. Both are accessed via GET.

Writing a module for this is really simple. I just needed to provide two functions (read and write) that take the correct arguments. Here’s what the module code looks like, including the tests that are embedded in the ruleset:

Importing the module into another ruleset is as simple as entering your StringBin PIN in a key block and then including this in the meta block:

use module a163x63 alias stringbin with stringbinkeys = keys:stringbin()

Here’s what it looks like in a full ruleset:

Feel free to use this module and let me know what you think of it!

TomatoFlix

Do you ever use Netflix.com or IMDB to look for a movie you want to watch? How many times have you wanted to know the Rotten Tomatoes ratings for a movie you were considering at the Redbox?

Enter TomatoFlix.

I wrote an app using Kynetx that takes advantage of the Rotten Tomatoes API and displays ratings on the movie detail pages of your favorite websites. Part of this I did for the Kynetx developer contest last week, but I didn’t get very far. It only worked on Netflix, and it wasn’t very pretty. Tonight I had some free time, so I improved the UI and added four more sites: IMDB, Redbox, Fandango, and Movies.com.

Here’s what it looks like for Tangled on IMDB:

If you’re a frequent moviegoer or movie renter, this is definitely worth checking out.

Find the app here on the Kynetx marketplace: TomatoFlix.

Creating a watermarked image in Python

Applying a watermark to an image in Python is a fairly simple process, but there don’t seem to be many good tutorials on how to do it. This is a very simple example that creates an alpha layer, positions some text in the upper left hand corner, and fades it. It then applies the layer to the original image and saves it to disk. Here’s what it looks like:

Hopefully those comments explain things well enough.

You can save out the image after each step and watch the transformations if that is helpful for understanding what’s going on.

NOTE: This uses the Python Imaging Library, which is in the python-imaging package on Ubuntu. Make sure that’s installed.

Employment and networking: Down with resumes

A friend of mine, Q. Wade Billings, wrote tonight about the uselessness of resumes in the job search (whether for employees or employers). He postulates that

If you want to find great people, you will not find them sorting through stacks of paper. You will only find great people by using your network to solicit personal recommendations. . . .

Instead of looking at a resume, ask the candidate for their LinkedIn profile or their Twitter name. These glimpses into the person’s social graph will tell you more about who the person is and what they are all about than their resume ever could.

I couldn’t agree more. I wrote last spring about how I got a job as an intern at Kynetx because of what Wade described: networking.

As a bit of an illustration, take my work history for the past five years. In 2006, I went searching for a job in the traditional way: job boards and resumes. Eventually I found a good job as a programmer at BYU. Since that time, I have worked at or with seven different companies or organizations. In all of that time, I never applied for a job. People sought me out because they knew me through social networks or friends in the industry.

Like Wade says, LinkedIn, Twitter, and my blogs give a much better picture of me than a resume ever could. They describe who I am, what I like to do, what interests me, and the people I know and work with. And they do it in a very dynamic, descriptive way. Resumes are a relic of the past and simply don’t make sense for the hiring process anymore.

I’m a college student right now, so that gives me a lot more flexibility in employment, since I don’t get a salary or benefits. That gives me opportunity to work with a lot of different people and build a network that will be critical to my success after I finish school. I can’t say for sure yet, but I imagine that when that time comes, I will find full-time employment through that dynamic network of people and not through a static resume.

Writing daemons in Python

Labs 4 and 5 require a few daemon processes to monitor SQS messages. To make it easier for you, there is a Daemon class you can use. Simply subclass it and override the run() method. You can find the code listing here:

A simple unix/linux daemon in Python by Sander Marechal

I’d link to put some links here for other languages like PHP and C#, too. If you have information about those, please leave a comment below.

Programming SQS with Python and Boto

In my last post, I left out a few details needed for Lab 4. One of those is Amazon SQS: Simple Queue Service.

You’ll notice in the comment function of simpledb.py that there is an invocation of funcs.addCommentToQueue(). I won’t show that function here, but I’ll give you an example using a test queue. The analogous function here is called addMessageToQueue().

Reading messages from SQS is pretty simple too. The second function, readMessageFromQueue(), gets all the messages currently in the queue and prints them out.

If you run this a few times, you’ll notice some interesting behaviors:

  • Messages do not make it through the queue immediately. There is some latency.
  • Messages are not guaranteed to come in any particular order.
  • Messages may come more than once.

These limitations are just fine for our system, because we’re using them mainly to handle batch tasks (image processing). You probably won’t run into trouble with them, but you need to be aware of and handle these cases in your code.

Here is the supporting code for the above examples:

When you actually implement Lab 4, you will use a daemon. I will write more about that later. Basically, it will entail using a while loop and reading one message at a time, not in bulk like this.

Here is a good tutorial with a few more details than I have gone into here: An Introduction to boto’s SQS interface.