I have been using the Python Debugger aka pdb docs for 2.7/docs for 3.5 a lot recently and wanted to share a cheat sheet I found and also the common commands I use.

The cheatsheet:

pdb cheatsheet

The easiest thing to do is put the following in your code somewhere:

    import pdb; pdb.set_trace()

Then when you run it, it will stop there and you can step through the code a line at a time. The l(ist) command will show you 11 lines of code around the current line is the one I use the most. s(tep), n(ext), r(eturn) are some other I use regularly.

Once the debugger is up, you can check the stacktrace w(where), variable values a(rgs) or [variable_name] or many other things. Please check the documentation or the cheatsheet image above.

A much more in-depth usage of pdb can be found here

Cheatsheet image credit

Originally posted on 03-03-2014 and continually updated

Will be adding to this post as I learn/remember shortcuts

  • . - repeat last command in normal mode
  • @: then @@ - repeat last command entered with : source
  • # - find all occurances of the word I’m currently on
  • dfc - delete everything including the letter ‘c’
  • dtc - delete everything up to the letter ‘c’
  • :e! - reload current file (typically after doing a git pull)
  • :b# - go back to previous buffer
  • shift+h - go to top of screen
  • shift+m - go to middle of screen
  • shift+l - go to bottom of screen
  • ctrl+v [h|j|k|l] - highlight individual items (great for highlighting column(s)
  • gUiw - capitalize the current word
  • gUU - capitalize current line
  • vU - capitalize current character
  • guiw - lowercase the current word
  • guu - lowercase the current line
  • vu - lowercase current character
  • [num]j - go down num lines from current line
  • [num]k - go up num lines from current line
  • ctrl+O - jump back to previous (older) location in file info
  • ctrl+I - jump forward to next (newer) location in file info
  • ctrl+w + [H,J,K,L] - move current window to the far left, bottom, top or right

keybindings I use all the time via mappgings in my .vimrc

  • ,v - create vertical split
  • ,h - create horizontal split
  • ,= - reset split to equal sizes after parent window resizes
  • ctrl+j - go to split below/down
  • ctrl+h - go to split on left
  • ctrl+k - go to split above/up
  • ctrl+l - go to split on right

With the jedi-vim plugin installed for Python:

I’ve been interviewing a lot lately since I was let go from my last gig. During the interviews I’ve been asked a few times when and why I started programming. My answer is the following:

  • I wrote my first program in the Basic programming language when I was eight years old (1988) and loved that I could control a computer and build software.
  • In 1991 when QBasic came out I learned about the easter egg that you can do when starting QBasic from a DOC prompt. The easter egg showed “The Team of Programmers” that created QBasic. Once I saw that, I told myself I wanted to be one of them.

QBasic Team of Programmers Easter Egg

  • The idea of learning another business industry so I could create software for them excited me. Here are some of the industries I’ve learned through my career:
    • Banking
    • Oil & Gas
    • Hosting
    • Medical
    • Daycare
    • Salon
    • Restaurant/Service
    • E-Commerce
    • Sports Merchandise
    • Home Security

UPDATE: Looks like this post is moot as of today 3/24/2016 due to Docker for Mac and Docker for Windows betas coming out

While interviewing for a new gig I was asked to use memcached and they had suggested standing up a docker instance. I have been using docker pretty regularly now after learning much from my previous co-workers and practical usage.

So, on OSX you can install the docker-machine and docker brew formulas with homebrew. (If you are not using homebrew and cask to manage your installations on OSX you are missing out). I use VirtualBox as my VM hosting tool.

If you haven’t installed (tapped) cask for application (non-CLI, GUI apps) installations, you should do it now:

brew tap caskroom/cask

Now install the items:

brew cask install virtualbox
brew install docker-machine docker

On Linux you don’t need docker-machine as you can just use docker directly, but on OSX you need the set up a Linux host through a VM tool like Virtualbox. You need to setup your docker-machine with the following command:

docker-machine create --driver virtualbox default

This creates the docker host on virtualbox and names it default. So when you run docker-machine ls you will see something like the following:

› docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   *        virtualbox   Running   tcp://           v1.10.3

I created a Dockerfile to create the docker image with the following content:

FROM ubuntu:latest
MAINTAINER Jason Meridth <jmeridth@gmail.com>

RUN apt-get update && \
    apt-get install -y memcached && \
    apt-get clean

EXPOSE 11211

CMD ["-u", "root", "-m", "1000"]
USER daemon
ENTRYPOINT memcached

This Dockerfile will do the following:

  • create a new image based on the latest Ubuntu docker image on DockerHub.
  • set the maintainer to myself
  • update the instance
  • install memcached
  • cleanup the update/install
  • expose port 11211 from the instance
  • run the arguments against the entry point (memcached)
  • set user to daemon
  • set entry point to be memcached

After the docker host is create I then built the image with the following command:

docker build -t memcached_img .

-t lets you set a tag on the image so you can use that instead of the unique ID when creating the instance.

To see the new image you run the following:

docker images

and you’ll see something like:

› docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
memcached_img       latest              ad3d86685ca8        57 minutes ago      211.4 MB
ubuntu              latest              97434d46f197        4 days ago          188 MB

Note: To delete the image you would use the docker rmi memcached_img command.

I then created the docker instace based on the new docker image with the following command:

docker run -name memcached_ins -d -p 45001:11211 memcached_img

You should receive the sha of your new container instance. To see the instance information run docker ps. The result is

› docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
18c82cd27a2d        memcached_img       "/bin/sh -c memcached"   5 seconds ago       Up 5 seconds>11211/tcp   memcached_ins

As you can see this shows the mapping from the host port of 45001 to the container instance port of 11211 (defaul for memcached).

Note: You may need to add the -a argument to the docker ps command to see all container instances (including the ones not currently running).

From a former colleague at Rackspace, whom I asked for his top leadership advice:

  • you work with me, not for me
  • consult rather than dictate
  • manage to the outcome
  • understanding how you are communicating is just as important as what you are communicating
  • treat everyone the same