What Are Your Negative Gains?

I came upon a helpful tool for diagnosing why I sometimes do things that logically seem to be against my best interests. Odds are, you are probably doing it too without even knowing it.

The concept

The concept is “negative gain.” It is the positive reinforcement that one gets for doing behaviors that have negative results.

It is easier to make the changes you want once you are aware of what you get out of being the way you are. This is called the ‘negative gain’. It is what we give ourselves for unconsciously not choosing to be or do what we want out of fear of failing.

A negative gain provides a temporary compensation – a kind of second best – for finding an excuse not to do what we want to do, because our fear prevents us. Negative gains are false friends, because they seem to make us feel better in the short term, but turn out to be a sham as we realise we are failing to make things better for ourself.

We even feel worse when we keep on using the same old mechanisms of avoidance. Negative gains are different from 'rewards’ where we have chosen to be or do what we want. Examining some typical negative gains should make the concept clear…

Read on →

Write-Copy-Fix-Refactor

Was writing some code the other day, and then wanted to have similar functionality in a different area of the codebase. I did not want to directly copy and paste, as I consider this to be a very recognizable code smell. Basically, copying and pasting is a clear indicator that there is similar structure that is not being realized. It is similar to making up really complicated equations and models for why planets in the sky do loop-de-loops, and then understanding that they all revolve around the sun. That understanding simplifies things.

However, it was tough to think about what needed to be abstracted out of the solution that I was going to use. What I did was to copy the original to another area, change it to work in that context, and then factor out the common parts as best as possible to a library function. I expect to use this function a few times, so this seems to make the most sense from a flexibility and maintenance perspective.

Read on →

Avoiding Email and Twitter Overload

I recently watched Randy Pausch’s lecture on time management (1 hour). It’s a good reminder of things to consider when dealing with people and simultaneously trying to accomplish great things. Inspired, here are some of my communication management hacks.

Generally, I subscribe to Paul Graham’s Maker’s Schedule, Manager’s Schedule. I attempt to identify large blocks of uninterrupted time using the fold calendar and then avoid interruptions while I get stuff done.

Sometimes I’m not looking to get that much done, so I disregard these concepts. But they have served me well in times of need.

Communication notification philosophy

Basically, turn off real-time automatic notifications of communication while leaving some channel for messages of critical importance.

I like Tim Ferriss’s adage of “sometimes you need to let small bad things happen to get large good things done.”

Email is simply not the correct medium for anything time-sensitive because it is asynchronous. You should not expect a response in less than three days to email you send, and you should not need to respond to emails in less than a day. No email should be important enough to warrant blocking the most important thing you should be doing. If the concern truly is pressing, the person will just have to call you. Set the communication guidelines clearly, and help others understand how you can best be reached.

Read on →

No such file to load when running Ruby 1.9.2 on Ubuntu

I have an existing Rails repo that is trying to run Ruby 1.9.2. I attempted to check out the code and get things running, but had a small problem.

$ rake spec
(in ...)
rake aborted!
no such file to load -- net/https. Try running apt-get install libopenssl-ruby
(See full trace by running task with --trace)

Although I tried sudo apt-get installing the various libopenssl-ruby and libopenssl-dev and whatnot, I kept getting the same error message.

Read on →

Ruby Pretty-Print XML

It’s fairly easy to do with some Rails libraries, although it’s different from the way that most people have suggested online due to Rails 3 changing the way that some things are laid out. If you want to use IRB or something else to pretty-print XML with Ruby, try the following:

require 'rubygems'
require 'ap'
include ActiveModel::Serializers::Xml

raw = File.read(filename)
parsed = Hash.from_xml(raw)
ap parsed

The ap is the awesome-print gem. It prints out the resultant structure in an easy-to-read format. I like the output of ap better than pp, and I like using RoR’s from_xml better than, say, REXML, Nokogiri, or XmlSimple. For the first two, you basically have to roll your own pretty-printer (from what I understand). XmlSimple works, but the output seems to be a bit funky (too many arrays for keys, etc.)

Read on →