Blog of Spencer Dixon

Software Developer & Mentor at Launch Academy

The Stages of Vim

| Comments

So you’re finally fed up with alerts asking you to buy Sublime text or random errors with Atom? Time to transition to the editor that has been around for over 30 years Vi Improved, also known as VIM. Getting started with VIM can be difficult so I decided to write a post on how I approached it. The first thing to understand is learning VIM is NOT easy but once you do it you will never regret it. Here are the stages of VIM:

Optimistic Hatred

At this point you see the value in learning VIM but the learning curve is making you hate it. Every time you start to use it you get frustrated and just open a text editor your comfortable with. The idea of using hjkl to move around makes you crazy. Why would they do that!? The best way to overcome this stage is to just go cold turkey. Declare to the world that you will no longer ever use your old text editor. It’s VIM or no programming. The only way you are going to climb the wall is if you completely dedicate yourself and stop trying to learn it here and there when you have time.

Resources For Stage 1:

  • Vimtutor. Enter your terminal and type vimtutor + enter. Follow that tutorial. Do it twice.
  • Vim Novice Tutorials – Watch all these videos. Take notes, pause the videos and try to do what is being taught.
  • Get your VIM set up properly: Here are my dotfiles Clone this repo down to your home directory (~) and then run ./install.sh to execute the script that will get you set up.
  • Vim Adventures – more practice with hjkl, fun when you’re bored of learning from other materials.
  • Remap your capslock to be something useful: control. You will be hitting ctrl + c constantly in vim to switch modes. Having caps lock as control can help with keyboard shortcuts outside of VIM as well. Ctrl + tab will cycle your tabs in chrome.
  • The hardest thing to overcome in the beginning is just getting VIM set up properly. Here are some of the MUST have plugins that I use: NerdTree, ctrlP, and vim-ruby
  • Install the vimium plugin on chrome. Now you can practice your vim everytime you search the internet! Vimium download

There are many more plugins you will want. For now what’s important is you can access your file tree using NerdTree, you have a way to search through directories using ctrlP, and you have some ruby helpers. Focus your attention on overcoming hjkl and learning basic commands like d, y, c, w, p, etc.

Fixing Travis CI Api Keys

| Comments

Working on a project I encountered an error where the gem I was using, VCR, required an API Key for my local tests. I thought that dotenv-rails would have loaded my keys in the Travis environment but that wasn’t the case.

I was using the VCR gem to save snapshots of HTTP requests for testing purposes. It was driving me nuts because locally all my tests would pass yet whenever I tried to merge on github Travis threw me errors.

Here was the solution:

1
2
gem install travis
travis encrypt ENV_KEY=<value> -r github_username/github_repository --add

If you ever get weird Travis CI errors when using the VCR gem try explicitly setting your API key’s and see if that fixes things. :)

I’m primarily documenting this for my own sanity in case it ever happens again, but hopefully someone in the interwebs finds this useful.

Integrating Flowdock Push API Into Rails

| Comments

Integrating the Flowdock Push API is a lot easier than I thought it would be. I decided to document how to get it set up.

Step 1 – Add Gems

Add these gems to your Gemfile:

1
2
gem 'flowdock'
gem 'dotenv-rails', :groups => [:development, :test]

Then run bundle.

Counter Caching in Rails

| Comments

Finding Number Of Answers For A Question In Rails

Earlier this week I was given a pretty straightforward user story of figuring out how many Answers a given Question had received.

Wrote my acceptance tests and then was surprised at how complicated this was to actually implement. After devouring the Active Record documentation in hopes of finding a method that would leverage the two models associations I ended up bootstrapping a method to get it to work:

1
2
3
4
5
6
7
8
9
10
# in Question Model:
def self.unanswered
  unanswered = []
  Question.all.each do |q|
    if q.answers.count == 0
      unanswered << q
    end
  end
  unanswered
end

Gosu Tutorial

| Comments

Getting Started With Gosu

This is a basic tutorial to help Rubyists interested in Gosu/Game Development to get started. The game we will be making is Rock, Paper, Scissors.

When I was first introduced to Gosu it was an intimidating experience which is why I wanted to create this tutorial. After getting an understanding of the basics I realized how simple Gosu really is.

Gosu is a fantastic way to get a deeper understanding of Object Oriented Programming. It’s also extremely rewarding being able to create your very own game from scratch.

One of my favorite parts of Gosu development is that even though there are certain methods you NEED to use most of the logic is left up to YOU the programmer.

Prerequisites

  • Basic undestanding of Ruby Classes
  • Basic understanding of Modules
  • Basic understanding of inheritance

Table Of Contents

Rails vs. Sinatra

| Comments

The excitement and suspense of starting Rails has been huge for me these last couple weeks! After 5 weeks of learning how to program, figuring out what params are, and designing some basic websites we have finally entered the realm of the Big Framework.

Halfway Through

| Comments

Officially halfway through my time at Launch Academy! One of the most exciting things for me so far has been the amazing community Software Development has. Everyone is very open to help and willing to share valuable advice. Attending the E4E conference last friday really opened my eyes to how great the community is. Looking forward to my second half and having some free time to work on personal projects. Hand is still hurting from tendinitis so going to keep this post short and sweet :) Until next time…

Metaprogramming, Algorithms, and Procs Oh My!

| Comments

This last week was packed with juicy new concepts for me to figure out. The core work revolved around Object Oriented Design which was great. I find OO to be extremely fascinating because it’s essentially just designing complex systems. Maybe I’m weird but I love developing systems, using systems, and improving systems.

Launch Week 3

| Comments

Week 3 was probably the most painful week of launch. Ironically not in the sense of difficulty but my hand is absolutely killing me from typing so much. I’m probably going to need to go see a doctor to get some sort of brace.

Launch Pairs

| Comments

After learning about compound data structures I was able to create simple Sinatra apps using other people’s data. However, not being able to interact with databases was a huge hindrance on my creativity. There was no way for me to save information past a given session.