TheJoyOfHack

For people who like to make things

Shell Tricks - Extracting A Column From A Text File

There have been times when I’ve had to extract a particular column from a tab-separated or comma-separated file. The best way to do this is to use the shell command cut. Let’s say I have a file named input.txt that looks like this:

more ...

Excluding Yourself From Google Analytics

In my last post I wrote that I followed some instructions to exclude myself from Google Analytics’ reports on my Octopress blog. There was an error in the Javascript that was preventing the required cookie from being set. Here’s what I did that finally worked:

more ...

Switching To Octopress

Over this past weekend I switched my blog over from WordPress to Octopress. In this post I write about why I did it, what exactly I did to get the blog just the way I wanted, and what I plan to do in the future.

more ...

How To Wrap Text In Vim

[Another in my series of posts on Vim]

If you’re writing natural language text you may wish to format your paragraph so that the text wraps before lines get too long. Here’s how you do it:

To set the maximum width of a line of text, go to Normal mode and enter

:set textwidth=72
more ...

Understanding Your Camera’s Histogram

In a previous blog post we learned what a histogram is.  In today’s post we’ll see how to use histograms to help take properly-exposed photographs.  If you haven’t read the previous post, or are not familiar with histograms, I would recommend you read that post before continuing with this one. more ...


Inspiration vs. Imitation

Jessica Hische has just published a very well written article on “why it’s ok to copy people to learn, but never ok to publish that work.”  I love the tone of her writing.  Even though I’m not a designer and won’t ever be as good a letterer as she is, I hope to be able to write as well as her.

more ...

How To Quickly Delete Words While In Insert Mode In Vim

[Another in my series of posts on Vim]

Sometimes when you’re typing natural language text, you find yourself wanting to rephrase the sentence you’ve written so far.  You could hit backspace many times to delete the characters to the left of the cursor, or you could type Ctrl-W.  When you’re in Insert mode, Ctrl-W will delete from the cursor to the beginning of the previous word. more ...


What Is A Histogram?

A key aspect of good photography is exposure - the amount of light that enters the lens.  One of the most useful tools a digital cameras has to help you measure a photograph’s exposure is the histogram. In order to learn how to use it, you must first learn understand what a histogram is.

Let’s pretend I teach a class of 20 students. One day I decide to give the students a test in which they can score anywhere from 0 to 100 points.  After grading the tests I want to see how the population of students did.  So I graph the scores in a histogram. A histogram displays the distribution of measured values across a population.  Let’s make one now. more ...


How To Insert A Line Of Dashes In Vim

[Another in my series of posts on Vim]

If you’re a developer, you will often find yourself having to insert a line of dashes or hashes (#) or asterisks into your comments.  In this post I’ll show you how to do this quickly.  Memorize this because you’ll wind up doing this often.  Position the cursor to the beginning of a blank like (in command mode) and enter the following:

80a#<ESC>
more ...

How To Subtract One File From Another

Let’s say you have two text files, FileA and FileB.  You want a file that has all the lines of FileA that are_ not_ in FileB.  How do you do that?

The simple answer is grep. The -v option inverts the search, and only prints lines that do not match.  The -f option is used to specify a file that contains a list of all the patterns for which to look - one pattern per line. more ...