TheJoyOfHack

For people who like to make things

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 ...

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 ...


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 ...


There and Back Again - A Hacker’s Switch from Emacs Back to Vi

When I first learned how to exist on UNIX, in 1988, I used vi as my primary editor. During the next nine years I taught myself how to become a power user - migrating from the simple motion and copy and paste to more complex skills like marks and named registers. When I started graduate school I saw many of the professors and grad students using emacs.  I tried it out a couple of times, but it was not until 1997 that I decided to take the time to stick with emacs and take the time to learn the right way to do things even when I could get the job done faster in vi. more ...


Taking Back My Relationships

I’m trying to formulate a sensible strategy to overhaul my net presence. The rough plan so far:

  • Change my 12-year-old email address that is on every spammer’s short list
  • Extract friends’ contact info from Facebook
  • Delete Facebook account.
  • Import FB contacts into Google & Mac
  • Redirect facebook friends to current tech blog (aijazansari.com) and new personal blog.
  • Find out if FB friends can subscribe to an RSS feed of my blog somehow (doesn’t seem possible any more)
  • Pick up the phone and actually talk to friends more often.

The goal’s pretty obvious - I want to reclaim my data.  I think I own my relationships, not FB, not Twitter, and not Google+.  So far, G+ may be the most accommodating network out there - if I can export my G+ presence as easily as I can export my G+ contacts, we might have a good candidate here.

If you have any ideas or comments or experience with this, please let me know.

I’ll keep you posted.


Update 2012/06/30

Like so many of you, I’ve given up on Google+. Most of the people I wanted to communicate with never made the switch. In the end, having those lines of communication open with my friends was more important than the platform. G+ has been dismissively called a “Ghost Town,” and in my case, at least, that wasn’t too far from the truth.

more ...

Implementing Inertial Scrolling in iOS

I hadn’t really given much thought to how the iPhone handles scrolling until I recently had to implement it myself. I needed to add vertical scrolling to a UIView that models a real-life metaphor. In my particular case I feel using a UIScrollView would break the metaphor - the user would “snap out” of the immersive app and realize they’re merely using an iPhone app with a pretty skin. So the natural solution was to implement scrolling myself. This is how it went from simple, unnatural scrolling to its current state of acceptable inertial scrolling. more ...


Hello, World” on the iPhone

Hello World on the iPhone
Hello World on the iPhone

Yesterday I started learning how to write applications for the iPad and the iPhone.  There are so many books that promise to teach you everything you need to know that picking one or two (or three) can be very difficult.  While I normally like to learn new skills by reading a good book, I think for iOS development a more dynamic source would be a better choice. more ...


Processing A List Of Files In bash

When you’re working in Unix or Linux or even Mac OS X, there are often times when you need to apply the same command to a list of files.  In this post I’ll show you a couple of quick ways to do this using the bash shell. more ...


Backing Up Data With rsync

At the Agra Fort, on the way to the Public Hall
At the Agra Fort, on the way to the Public Hall

In a earlier post I wrote about how important it is to have your data backed up.  On my Macs, my main backup utility is Time Machine, which comes pre-installed with the Mac OS.  Time Machine can also back up external hard drives, even though it may not be obvious how to do it.  This article shows you how to change the default settings to do this. more ...