My talk about Redacted Tweets

Last month I gave a presentation about my Redacted Tweets project at my local python users group, PyAtl.

Originally it was supposed to be a lighting talk, but I stretched it out to a full talk because one of the scheduled presenters couldn’t make it. Thankfully it is an entertaining story and everyone seemed to really enjoy my presentation.

Here are the slides that I presented. It was a lot of fun to tell everyone about this goofy little project. If you have any projects like this laying around, I would encourage you to present them at your local meetups! It is fun to share what you work on, especially if it is something funny that can make people laugh.

Hiring Hacks: Track your activity

When looking for a new job it is very easy to get overwhelmed, yet feel like you are not getting anything done. This combination can lead to a negative feedback cycle which leads to you feeling worse.

To prevent this, every day you should write down the activities that you did. And just as  importantly, you should write down the results. Let’s look at why and how this can help.

What did I do?

There are 24 hours in the day. Each hour is composed of 60 minutes. Every day we all do a countless number of things, some important, but most are mundane. (Think of things like drinking water, looking out a window, etc.)

If you take the time to write down the important things, they will stand out in your mind. The more they stand out to you, the more attention you will pay attention to those tasks. And if the task is important and you are paying more attention to it, you are more likely to do a “better job” with it.

But what’s important? It all depends on what your goal is. If you want to get a new job, then anything that gets you closer to that goal is important. This includes sending out resumes, talking to people, and any kind of reading or practice that you do to help you improve your skills.

Think about it: If it is important to get a job and your track “important” activities such as emailing your resume, you’ll start to notice how many times you’ve sent your resume out.

Why track these things?

It can be hard to make ourselves do something we find un-fun or unpleasant. But one thing that that humans are very good at is playing games. Think of all the hours you’ve spent playing games. Things like Famville, twitter, and traditional video games tend to be lots of fun, that’s why we do them!

If you start tracking how many resumes you’ve sent out, then it will start to look like a game. “Yesterday I sent out 3 resumes and got 1 phone call. I wonder if I sent out 6 resumes if I’d get 2 phone calls?”

Doing important things

Once you start tracking what you did, you will notice that your activities tend to cluster together into certain categories. For me, I’ve noticed it tends to be “entertainment”, “learning”, and “job hunting”.

From those 3 things its pretty clear that one of them is going to be pretty important if I want to get a new job. The other two are important, but if I’m doing them too much, then I’m not going to be moving closer to my goal of getting a new job.

By make a list over several days you too can start to see where you are spending your time. Ask yourself this question: “Am I doing the things that are going to get me closer to my goal?” If the answer is no, then It should be pretty clear what you need to stop doing in order to make the change.

One more thing: tracking what you do helps out if you need to file for unemployment. Typically if the government is going to give you money they want to know what you are going to do to “earn” it. Being able to show details of your day shows that you are serious about getting back into the job market.

Wrapping up… for victory!

Its easy to lose track of time and focus while job hunting. Here’s what you need to do:

  • Every time you do something important, write it down!
  • Every day, look at what you’ve accomplished
  • Every week look back at what you did
  • Decide what was important, and do more of that!
  • Decide what wasn’t important, and do less of that 😉

Using these hacks you can get your brain focused and see the progress you are making, and more importantly get to your goal faster!

Hiring Hacks

Recently I’ve found myself in the job market. In the past when faced with this situation I’ve simply thrown my resume out there and hoped that someone would see it. These days though, I tend to follow a better strategy to make sure more people get to learn about me. Here’s what I’m doing:

  1. Make sure your resume is on a public webpage somewhere.
  2. Use a link shorting service like bit.ly to create a link to your resume
    1. Optional: make the shortened url something unique like your name
  3. Post your shortened link in your various social media sites.
  4. Go to bit.ly and check the stats on your resume!

One version of a resume

In step #1 what you are doing is making a central copy of your resume. A big problem is that recruiters and hiring managers will get emailed a copy of your resume and will then put it into their system. Over time you might want to update your resume, but those old copies are still out there! By having a single copy that is publicly visible you can always point people to the “latest and greatest” version of your resume. And any changes you make get seen right away.

Personally, I have my resume in a Google Drive Document. In addition to being a full document editor like Word, they allow you to share a document as read only (or editable, but I would not recommend that for an important document like your resume!). As a bonus, if someone looks at the document while you are looking at it too, you can see where their cursor is, and that might let you know what is the most important sections.

The link

bit.ly is an awesome little service. It lets you turn long web addresses into short little links which are perfect for instant messages or tweets. (The shorter the link, the less likely someone is to mess it up!)

Sign up for a free account there, and then you can put the link to your resume in and create a shortened link. As a bonus you can specify what the shorted link looks like you can personalize it.

I did this and it gave me the link: http://bit.ly/1EGdxOx which points to my resume hosted on google drive. That link looks much nicer than the normal google drive link (which is https://docs.google.com/document/d/17R6XoxhaUt5ywEKinZVSDYqQaJGRLJVEnOu5LaVkmzY/)

If you don’t want to create an account on bit.ly there is still a way to check on your stats. Read on for more info!

Tell the world!

Every social media site claims that they are the hottest spot, but how do you really know? By sharing this shortened link on your various accounts at the same time you can find out exactly who is interested!

I shared my link on Twitter and LinkedIn because those are the two spots where I’m most active. Both of these sites have the ability to tell you a little bit about your posts: Linked in can tell you how many people have looked at your profile, and twitter can tell you how many people clicked on links.

But one thing they can’t tell you is how many people looked at the link and then shared it via email or instant message. This is where the bit.ly link comes into play.

Is anybody out there?

Once you’ve shared the link then you can visit your bit.ly account and view the stats for your link. Here’s a picture of what mine looked like:

Screenshot

I created the link and tested it out. I then waited until Monday morning and then posted it around 7:30am. That’s the huge spike there. As you can see there were over 30 views! This is great information to know because it lets me know how active my resume is. As the week goes on I can re-send out the link and I should see a new bump. This is important to know because if I just sent the link out again on Tuesday it might not have been seen by as many people.

Further down the stats page is another important chunk of information, how the link was shared:

Screenshot-1

This was very interesting to know. I have a similar number of followers on both LinkedIn and Twitter, but twitter was twice as much as LinkedIn! And the “Unknown” was huge! The “Unknown” was for referrers that didn’t identify themselves to the browser. So that could be email links, chat messages, or some other situation.

(The “Who shared a bitlink” thing shows me because I’m the only one who posted this link to bit.ly which isn’t surprising: this type of link it going to be shared via copy-paste instead of someone retweeting it.)


BONUS HACK!

If for some reason you don’t want to make an account on bit.ly (no judgements, I totally understand!) here’s a neat little hack you can do to find out some stats:

Take any bit.ly link and put a + at the end of it. This will tell bit.ly to take you to their stats page for that link. This works for pretty much any bit.ly link and it is really interesting to see how some links are spread across the internet. Thanks to Hilary Mason for this awesome tip!


Measuring the effect

The goal of all this is of course to get a new job. Normally I would just measure my progress by the number of phone calls and interviews that I’ve had. Now I have an additional data point of knowing where and when my resume has been read.

Thanks for reading! If you’d like to talk be to check out my resume or hit me up on twitter.

Installing OpenCV for Python on OS X

OpenCV is a computer vision library. It is a really powerful library and has bindings for Python. The only thing that it doesn’t have is a good explanation of how to make the python bindings work! Here is how I got it to work on my Mac (running OS X 10.9.5) inside of a virtualenv.

  1. Install cmake (brew install cmake) and the normal development tools
  2. Download and unzip the OpenCV code
  3. Change directories into the OpenCV directory
  4. Type in “cmake CMakeLists.txt”
  5. Type in “make -j5″ (this will use 5 threads and make the code build pretty fast)
  6. Type in “make opencv_python2″
  7. Type in “sudo make install” (to install all of the code)

At this point the python code has been installed to the main system python in /usr/local/lib/python2.7/site-packages which is not very helpful if you are using a virtualenv (which is what you should be using if you are working in python!)

The next step is to copy the OpenCV files from the global directory into your virtualenv. This is done by typing in the following:

cp /usr/local/lib/python2.7/site-packages/cv2.so <path_to_your_virtualenv>/lib/python2.7/site-packages/

This will copy the .so created during the build to your virtualenv which will make it accessible to your python code. At this point you should be able to fire up the python interpreter in you virtualenv and type in:

import cv2

and it should work. Happy Computer Visioning!

Making a plan B

There’s an old saying that “no plan survives first contact with the enemy”.

There is a lot of truth in that statement in a lot of situations. It would seem to say that we shouldn’t bother making plans, but I see it a different way: make plans that are flexible.

Rigidly following a course of action is rarely a good idea. Failing to recognize that something isn’t working is something a lot of people are able to do, but the critical second step is to make a change is something that is rarely done.

Having a Plan B is usually a good idea for anything important. But if your backup plan is just as rigid as the first plan you will have the same problems. A better approach is to make sure your plans can adapt to difficulties you encounter.

For example, if you are debugging software and nothing is working, try stopping what you are doing and approach it from a wildly different angle. You will still be accomplishing you goal (debug the software), but from a different angle.

This ability to change up your approach is the ultimate Plan B. It allows you to move forward maintaining your momentum. You still reach the same destination, but hopefully faster. The root idea is try and overcome your functional fixedness.

Here’s some random examples:

  • You have a flat tire. Your spare is flat too. How do you get the car/tire to the repair shop?
    • Call a tow truck?
    • Use a bicycle pump to get just enough air in the tire for you to drive it to the shop?
    • Take the tire off the car and get a friend to drive you to the shop?
  • You need to edit a large file on your computer, but you don’t have enough free disk space.
    • Delete other old files to free up space?
    • Try and hook up a USB thumb drive and do the work there?
    • See if there’s a way to do the work without copying?

There’s tons of situations in daily life that can be tackled in new ways. All it takes is the ability to remain fluid in our approaches to solving them.

Making Progress

I have a problem. Actually two problems.

One problem is that I have this feeling that I can’t shake. A feeling that I’m not doing enough, or getting enough things done. The second problem is that I have this strange hesitation to post on my blog these days.

The 2nd problem is related to twitter, I tend to post things there more frequently. Short thoughts, less friction. The first problem has a bit of a challenge to it.

Most people by default tend to look at their own achievements in a less-than-flattering light. I think the main reason for this is we tend to “forget” things as we get further in time from them. For example, if you had a really great day at work, but then had 2 weeks that were really bad, you won’t see the really great day as the accomplishment that it was: instead you are overwhelmed with the most recent events (which in this case were not so great).

I’ve decided to tackle both these problems by blogging things that I do shortly after I do them. This way I’ll get two birds with one stone; more frequent updates, and a record of the cool and fun things I’ve done recently.

Now having said all that, here’s what I did in Januaray:

Raspberry Pi – ZNC

Last year I got 2 raspberry pi computers. Very cool little machines, they are about the size of a credit card and are only $35. But… what should I do with them? An answer finally hit me in the form of IRC.

IRC seems to be making a comeback, a lot of interesting/cool people tend to hang out on it. So not wanting to be late to the party, I decided I would hang out there too.

The problem is I could be connecting to IRC from one of several different machine (work machines, home machines, phone, etc.). The solution is to use an “IRC bouncer” like znc to keep my connection. Znc acts as a single sign on point, I log into it, and it keeps my connections to the IRC network alive. It also logs the conversations so I can scroll back on different machines and never miss anything.

The only catch is that znc needs to be connected to the internet all the time to maintain the connection. Not wanting to keep my power-hog home PC running all the time, the flyweight raspberry pi suddenly seemed like the ideal server. It is low power (it runs off of a micro usb connection), and runs linux. The perfect combo!

So with a little research (several other people had the same idea) and a little bit of time I was able to quickly accomplish the following:

  • Setup a Raspberry Pi so it is on the internet 24/7
  • Setup a dynamic dns program so I can get to the Pi (even if my home network gets a new IP address)
  • Setup znc and have it connect to the IRC networks of my choice
  • Set up SSL so that everything on the IRC side is encrypted

The last one is my favorite so far. With all of the security talk going on, a little more encryption is a great idea.

I’ve got a few more network-aware apps that I’m thinking about putting on the Pi, but this is a great start. And the next time I do something I’ll have it posted here! A win-win.

Running python tests randomly with randomize

Recently I was having a conversation with a co-worker about some test problems we were having. While we were brainstorming the idea of running the tests randomly came up. A quick search showed that someone else had been thinking about this issue too, but it looked like it never went anywhere.

The code that we found was here on google code but from the discussion it seems like the code was never included in nose, nor was it submitted to pypi. There was what looked like one repository on github that had this code, but it too wasn’t in the best shape.

So… I decided to grab the code from the Issue on Google Code and start up a new Github repo for it. I added several tests and fixed 1 little bug that I found and today I released it to the world.

If you are doing testing with nose in python, you can check out randomize, a nose plugin for running tests in a random order. The main reason you would want to do this is to ensure that there are no dependencies between your tests. This is very important for unit tests, they should be isolated and independent. This plugin helps confirm that isolation.

How it works: Basically as classes are read into the testing framework the plugin gets called and it will apply python’s random.shuffle() to the tests to produce a random order of the tests. One shortcoming of the plugin is that is only shuffles the tests, not the classes that hold them. (If anyone is interested in implementing this, please feel free to send me a pull request!)

Installation is simple. On the command line just type in:

pip install randomize

and then you’ll have it installed and ready to run. To use the plugin, all you will need to do is this:

nosetests –randomize

And that will invoke it. When it runs it will print out a seed number and then begin executing the tests. If for some reason you need to re-run the tests (say to troubleshoot a test failure), all you need to do is run:

nosetests –randomize –seed=<the seed number>

and that will re-run the tests in the same order.

Why you need tests instead of comments

Today I saw this blog post from Timothy Fitz: I hate comments

My first reaction was to dismiss this as another anti-documentation post by a coder who prefers doing nothing but coding.

But…

Timothy makes some really good points. His intent isn’t to downplay documentation (something that programmers are notorious for skimping on), but rather to play up the need to keep your code honest.

The best example is when he notes that a unit test could replace a comment about what a function “should never do”. That is a really insightful statement. Instead of leaving a comment, leave a unit test. If you are using a continous integration system, it should detect if someone ever violates the intent of the function. A broken test is much more likely to be seen than a potentially out-of-date comment.

I still think comments aren’t the “trash” that many programmers believe they are, but I do think that a unit test would be of more value to the code base overall.

The funny thing is that if you get into an argument with a programmer about comments and you counter with “Well, lets replace it with a unit test!” I think you will find the programmer suddenly back peddling. If there’s one thing a lot of programmers like less than writing comments it is writing unit tests.

Which is a shame, because unit tests that give you high code coverage are so useful when you want to keep your system running correctly.

Today’s Django lesson

Today I was working on re-doing my main website. I have built the site in Django, and then when I’m ready to publish I use the static generator module to create an html snapshot of the pages that I then upload to the server. Basically I wanted the fun of using Django, but the ease of serving up static html pages.

The last time I did this, the version of Django was 0.9 and today’s version is 1.3.1. As a I started work on the site I discovered some things here and there that had changed in the years in-between those version. The one that bit me the hardest was this: I could view the main page (/), but any other page (including index) would give me a 404 error.

This was really weird because the mappings existed in the urls.py file, but a 404 error means it couldn’t be found. If it was a programmatic error you would expect a 500 error, but I never saw one.

Slowly but surely I tore the system apart looking to see what could cause mapped urls to disappear in Django. Eventually I discovered the root cause was how static resources are handled.

One of the changes in the new versions of Django was to add functionality for handling static resources. The biggest change (at least as far as my ancient code was concerned) was in introduction of the STATIC_URL variable. According the documentation this is the prefix for static resources (like css, javascript) that are referenced by the web page that is being built by Django.

In my laziness many years ago, I just plopped the main CSS file (and everything else) in the root of the web directory so that in the html pages didn’t have to have paths on them. So when I was adding the STATIC_URL variable to make sure my CSS file would actually load, I set the variable this way:

STATIC_URL = ‘/’

…because it wouldn’t let me put an empty string of ”. Well, it turns out that this was wrong wrong wrong. Django was looking at the incoming requests as I tried to visit the pages of the site and checking the static directory to see if there was anything there (which there wasn’t, just my CSS file).

Once I realized this, I changed it to:

STATIC_URL = ‘/static/’

…which basically forces you to create a directory to hold your static files. Which is right right right right. Basically Django was forcing me to clean up my act and code the site in a much cleaner manner. As soon as I did that all of the 404 errors went away and I was able to hit every page in my urls.py file.

Choices – The hidden powers of python

The other day I saw something about this interesting posting on Stack Overflow: What are the lesser-known but useful features of the Python programming language? As someone who loves to work in Python and is always looking for a better way to get things done, I had to read this article right away.

I was pretty pleased with myself that I knew a lot of the things listed, and I was really happy when I ran into some nuggets that I knew nothing about. For example, I did not know that you could do this in Python:

1 < x <10

To me, that is really awesome because not only is what you would write in a mathematical sense, but it also is much more concise and what you would see in a pseudo-code representation of a program. That is the power of Python, taking an idea (a computer program) and presenting it in a readable manner. Being able to use the above type of expression just takes us further down that path of readability and that is a good thing. And yes, you can write crappy code in Python, but at least you have the choice: many languages simply have one way to do things. Choices are good.

And speaking of choices, I thought this feature was very cool, even if I would never use it:

from __future__ import braces

That allows the use of {} instead of white space in a Python program. I know some people can’t stand the indention rules of the language and feel more comfortable when they are “braced” (for impact?), but the fact the language has features to be able to turn this on? That is 1 million pounds of awesome in  a 5 pound sack.

There is a ton of other neat tricks there, go and read up and see what you can do to make your code work more for you! Choice is a great thing. With Python, you have lots of great choices you can make. And if you decide to make no choices, you still wind up with pretty readable code which is always a good thing.