Jason Meridth's Blog Learn, Converse, Share

Personal VIM Cheatsheet

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’
  • 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

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:

  • ,d - go to source
  • :b# - go back to previous buffer (only if you have it set to buffer and don’t overwrite to split

Why I started programming

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

Getting Going With Docker

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://192.168.99.100:2376           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        0.0.0.0:45001->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).

Good Leadership Advice

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

Meta keys with iTerm and Weechat

Found this tip today about how to ensure your iTerm console sends +Esc to weechat for the meta keys to work properly.

To make alt key bindings behave well for Mac OS X iTerm2, go to Preferences->Profiles->Keys and click +Esc radio button for option keys.

I like to use meta+c to clear a buffer and meta+x to close a buffer. meta for me is the Alt key. Here is the keybindings in my .weechat.conf.