Erik Zaadi

The tales of a coding manager addicted to dad jokes

Recent Posts

Installing Bare Boned Ubuntu using the Mini ISO

After installing Ubuntu 12.10, I got annoyed by the amount of unneeded software installed, especially the commercial lenses, offering me to buy something for every program I want to launch.

I tried Unity for about two weeks, until I decided I have to change to something else.

I used Gnome 3 with Fedora for a while before, and I really like the native multiscreen support available, that allows you to have a second monitor that doesn’t change when you switch workspace. I missed the diagonal workspace switches from Gnome 2 (and Unity), but it was a pleasant desktop.

Unsubscribing to watching all repos in a Github organization

Github notifications are great, but if you are a part of any organization, it quickly get’s overrun with repositories that you aren’t necessarly active with’s notifications, making it hard to filter the important bug reports on you own repos.

To unsubscribe to all repositories in an organization, open up your watching page (Login first of course).

Copy the gist below and replace THEORG with the organization you wish to unwatch it’s repositories.

Using Live Reload with Octopress

Live Reload is an awesome Mac app and browser extension which reloads your browser automagically when editing a file. Needless to save, it’s a bliss, never to {CMD,ctrl} + R again.

For those of us who are Mac less, the App is of course not available. Ruby to the rescue!

Install the LiveReload browser extension, see long explanation.

Edit Gemfile and add the following two lines:

1
2
3
4
5
6
7
source "http://rubygems.org"

group :development do
  ...
  gem 'guard'
  gem 'guard-livereload'
end

Create a Guardfile with the following content:

Inheritance within Python Unit Tests

TL;DR: Grab the gist

Let’s say you have these classes in a python file:

And you want to write some simple unit tests for them, typically you’d do something like this:

running them with nosetests -v will get you the following result:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
nosetests -v test_components_verbose
user@host:gist-3731389|‹master› ⇒  nosetests -v test_components_verbose.py
Test that initialized is set. ... ok
Test A class constructor set something. ... ok
Test that initialized is set. ... ok
Test B class constructor sets something. ... ok

----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK

Although that might seem ok, there’s some code duplication here that is really annnoying. If ClassA where to inherit ClassB this would seem even more over verbose..

One year of Linux

A little more than a year ago, I started working at XIV (IBM).

The change was rather dramatic in terms of technologies that I work with. I went from being a .NET web developer to a python developer, dealing with a lot if IT and system.

Furthermore, I stopped working on a Mac (this is do miss), and have almost not touched windows for the entire year (which I haven’t missed at all).

jQuery Compatible JSONP with Nginx

I got inspired by this awesome article by Gabriel Weinberg to hack a bit on nginx.

It’s a great article which I highly recommend to read.

The part that specifically interested me was turning JSON into JSONP compatible calls, usable both for proxying remote / local apis that doesn’t supply JSONP functionality and for simple to padd local static JSON files.

What bothered me though was the fact that the name of the method to pad into the JSON response was hard coded.

Fixing Thunderbird crashes on load and Mutt fails with fetched mail

If you use your unix mail spool/box with any type of fetchmail (ahem fetchnotes), on rare occasions, the mail box might be corrupted, typically missing a single starting character.

Thunderbird will fail miserably without any explanations, and Mutt will complain that the mailbox is invalid.

Open the mailbox (/var/mail/$USER usually) in your favorite editor (vim of course), and have a look at the beginning of the file:

It should start like this:

Mocking Python imports

Writing unit tests with Python is a joy, especially with the excellent mock library.

You can tweak the language and mock almost anything to your will, making testing even the smallest of units very easy.

HOWEVER , mocking imports, when a class / module depends on imports which you might not have on your machine, such as windows modules (oei vei) when you are (and you should be) on a nix machine.

Solarized color scheme for Octopress

Created a solarized theme for octopress.

Inspired by Ethan Schoonover’s own homepage.

The source is as always on github.

To add this to your own Octopress instance :

1
2
3
cd /my/awesome/octopress/dir
git clone http://github.com/erikzaadi/solarized-octopress-theme .themes/solarized
rake install["solarized"]

zsh users : run

1
rake install\['solarized'\]

instead of the last command

Customize

To toggle between light and dark mode, edit sass/custom/_colors.scss and change $sol and ``$solarized`:

1
2
$sol : light; // light or dark -  Recommended: set $solarized  to the opposite of this
$solarized : dark; // code syntax highlighting theme

Screenshots

Dark

auto installing vundle from your vimrc

You should be using vundle

Vundle is a vim plugin manager, ala pathogen.

Vundle allows you to specify in your vimrc what vim plugins you wish to load, and it’ll automatically download (git clone if possible) and enable vim plugins.

Vundle can get a name of a plugin as it appears in the vim plugin directory, a github :user/:repo style string, and even a full git url.

1
2
3
Plugin 'Syntastic' "uber awesome syntax and errors highlighter
Plugin 'altercation/vim-colors-solarized' "T-H-E colorscheme
Plugin 'https://github.com/tpope/vim-fugitive' "So awesome, it should be illegal 

Vundle also updates your vim plugins with a simple command :