Configuring NERDTree window size with janus.vim

Configuring NERDTree window size with janus for vim

So recently I decided my NERDTree window size as I was using the janus vim distribution was too wide.

I managed to change it by doing the following:

Step 1 – Check out the current window size

1
2
:let g:NERDTreeWinSize
3

Step 2 – To set the window size to some other value:

1
2
:let g:NERDTreeWinSize=20
3

Note: Also, quit your window and reopen to refresh and see the changes.

Step 3 – To make this change permanent, put this line in your vimrc file:

1
2
let g:NERDTreeWinSize=20
3

Note: I tried this with: Vim 7.4 and Ubuntu 14.04

Alias and Alias Method

To alias or alias_method?, that is the question

What do alias and alias_method do?

Both alias and alias_method allow you to use a synonym for a method name in Ruby.

What’s tricky?

Take a look at the source code below.

01
02
class Politician
03
  def stump_speech
04
    "I will grow the economy"
05
  end
06
  def self.add_slogan
07
    alias :slogan :stump_speech
08
  end
09
end
10
 
11
class Mayor < Politician
12
  def stump_speech
13
    "#{super} of this city"
14
  end
15
  add_slogan
16
end
17
 
18
class Politician2
19
  def stump_speech
20
    "I will grow the economy"
21
  end
22
  def self.add_slogan
23
    alias_method :slogan, :stump_speech
24
  end
25
end
26
 
27
class Mayor2 < Politician2
28
  def stump_speech
29
    "#{super} of this city"
30
  end
31
  add_slogan
32
end
33
 
34
p Politician.new.slogan
35
# => "I will grow the economy"
36
 
37
p Mayor.new.slogan
38
# => "I will grow the economy"
39
# The alias method "slogan" is not able to pick up on the method "stump_speech" defined in Mayor
40
# This is because alias refers specifically to the stump_speech method as defined in the original location, the Politician class
41
# This is because the "self" object is treated as the value of self at the time the source code was read
42
 
43
p Mayor2.new.slogan
44
# => "I will grow the economy of this city"
45
# The alias_method method "slogan" is able to pick up on the method "stump_speech" defined in Mayor2
46
# This is because alias_method refers to the value of self at runtime
47

The difference is basically this: alias_method refers to the value of self at runtime and alias refers to the value of self at the original point in the source code where it was defined. That is why in the above source code Mayor2 can have his own custom slogan but Mayor cannot.

As Ernie Miller points out, since alias_method refers to the value of self at runtime, it could literally be pointing at anything, which implies you better have really good test coverage to avoid unforseen bugs.

This was an interesting point as I had originally preferred alias_method since it seemed more flexible, but now Ernie has taught me to proceed with caution.

Collection of Cool Tools for Web Developers

Junkfill - Automatically fill out random form data when testing WhatFont - Identify the font(s) used on a website Wappalyzer - Identify a website’s technology stack Postman

Continue Reading …

Lessons Learned Building a Rails Backed API

A few lessons learned from building a Rails backed API on HerokuThis year and last I learned a few lessons from building a Rails 4 backed API on Heroku.Lesson 1 - TDD is for clean, but not necessarily performant codeI wrote the first

Continue Reading …

A Simple Program to Help You Go From Ruby To Go

Dabbling With the Go Programming LanguageWith the rise of Go, I’ve been dabbling with it more and more. If you’re a Rubyist and you’re wondering how to setup Golang on your system, check out my article Setting Up Golang Like a Rubyist.The

Continue Reading …

Collection of My Favorite Ruby and Rails Performance and Memory Articles

This is a collection of my favorite articles on Ruby and Rails performance/memory issues. I'll be updating it from time to time.Benchmarking /

Continue Reading …

Setting Up Golang Like a Rubyist

Getting into the Go Programming LanguageI use Ruby in my day job, but recently I’ve been dabbling with Go. The install docs give you an easy way to setup if you’re on Linux:export PATH=$PATH:/usr/local/go/binBut I’m used to RVM and

Continue Reading …

My Year of Software – A Review of 2014

Ten software lessons in 2014Lesson 1 - Building a Rails APIIn 2014, I built a backedn Rails 4.2 API using the rocket_pants gem and used another Rails application to view the API data. I learned to watch how many objects I was creating and

Continue Reading …

Camel Casing Your API Response in rocket_pants

What is rocket_pants?Rocket pants is a gem that gives you a set of tools for building an API in Ruby with Rails.Motivation for camel casingThe developer team decided we wanted to return camel-cased json responses, e.g.,{

Continue Reading …

Testing Elasticsearch In Your Rails 4 Application With RSpec

What is Elasticsearch? Elasticsearch is an open-source real-time search and analytics engine that runs on top of Lucene, a Java-based indexing and search library.If you haven’t setup elasticsearch with your Rails application, you can read about

Continue Reading …