Skip to main content

Posts

Showing posts from January, 2014

Python: A lightning quick introduction to virtualenv, nose, mock, monkey patching, dependency injection, and doctest

pip pip is a tool for installing Python packages. Python 2.7.9 and later include pip by default. If you don't have pip, you'll need to install it . virtualenv virtualenv is a tool for installing Python packages locally (i.e. local to a particular project) instead of globally. Here's how to get everything setup: # Make sure you're using the version of Python and pip that you want to use. sudo which python sudo which pip sudo pip install virtualenv Now, let's setup a new project: mkdir ~/Desktop/sfpythontesting cd ~/Desktop/sfpythontesting virtualenv env # Do this anytime you want to work on the application. . env/bin/activate # Make sure that pip is running from within the env. which pip pip install nose pip install mock pip freeze > requirements.txt # Now that you've created a requirements.txt, other people can just run: # pip install -r requirements.txt nose Nose is a popular Python testing library. It simple and powerful. Setup t

Interesting Computer Failures from the Annals of History

If you're young enough to not know what "Halt and Catch Fire", "Killer poke", and "lp0 on fire" are, here's a fun peek at some of the more interesting computer failures, failure modes, and failure messages from the annals of computer history: Halt and Catch Fire Cyrix coma bug Pentium F00F bug Pentium FDIV bug Killer poke Scratch monkey Stuxnet lp0 on fire Write only memory Not a typewriter PC LOAD Letter Thanks go to Chris Dudte for first introducing me to "Halt and Catch Fire" ;)

Humor: More Knuth Jokes

When Knuth implements tail call optimization, it's actually faster than iteration. All of Knuth's loops terminate...with extreme prejudice. The NSA is permanently parked outside of Knuth's house, hoping that he might help them crack public key encryption. Sometime last year, Knuth gave them a copy of "The Art of Computer Programming", but refused to tell them which page the algorithm was on. Knuth taught a group of kids how to use their fingers as abacuses. It turns out that his method is Turing Complete.

Python: My Notes from Yesterday's SF Python Meetup

Here are my notes from yesterday's SF Python Meetup: Embed Curl John Sheehan. embedcurl.com It creates a pretty version of a curl command and the output. You can embed it in your site. shlex is a module in Python to do simple lexical analysis. 1-Click Deployment with Launch and Docker Nate Aune @natea There are 10 million repos on GitHub. The curve is exponential. appsembler.com It launches a Docker container. It makes it easy to deploy certain types of apps. You can embed a widget on your app that says "Launch demo site". docker.io (see also docker.io/learn_more/ ) He talked about Containers vs. VMs. Containers share the OS, so they launch very quickly. You can create new containers, and each container is just a diff of another container, so it uses very little space. Yelp: Building a Python Service Stack Julian Krause, John Billings They're moving toward a Service Oriented Architecture. There are over 100 engineers at Yelp.

Shooting a Screencast that Shows an IDE

Many moons ago, I had to record a screencast. Most of the screencast was spent looking at code in an IDE. I wanted the IDE to be fullscreen, but I also wanted the text to be readable, even when the viewer wasn't watching fullscreen. Furthermore, I didn't want to spend all day zooming in on the cursor; I wanted things to "just work". After playing around with settings way too much, this is what worked for me: I used Camtasia for Mac . I plugged my laptop into my TV (using an HDMI cable) and configured the screen to be 720p. That's the only easy way I know of to get the screen to be exactly 720p. I recorded the video at 720p. Hence, what was in the video matched 1 to 1 with what was on my screen. Here's a link to the original video . The video is quite viewable in a normal YouTube window, but if you go fullscreen, it looks even better. The text is very crisp once YouTube switches over to the 720p version, but it's still readable even in lower ban