I’ve been blogging for a few years now. Over the last few months, I’ve been keeping private notes regularly. I haven’t been returning to them much after I’ve written them.

Today I realized that twitter has been a bigger distraction for me than ever after many attempts to deal with it. So I stopped checking it. I was more productive at work today than I’ve been in months.

After thinking about it, I remembered that I’ve blogged about various ideas I’ve had for dealing with twitter productivity problems. I wonder if I would have come to the realization sooner if I made a habit of reading my own blog posts?

I also have a lot of ideas jotted down over the last few months that I haven’t returned to. I’m busy right now, but when I get a chance I think I’ll take a peek.

jQuery has convenience functions for events like click and keydown, and lets you create and use your own events with bind() and trigger(), but doesn’t provide a way to create your own convenience functions for custom events. I took several lines of code from the jQuery source and created a plugin that makes creating convenience functions as easy as calling $.convenience(‘nameOfFunction’). Then I can bind or trigger an event simply by calling nameOfFunction() on the selector. This should be apparent by looking at the demo source (the third link).

  1. jquery.convenience.js – plugin source (github)
  2. convenience.html – demo (my site)
  3. convenience.html – demo source (github)

The example shows one feature of custom events that I overlooked: propagation.

I had two twitter accounts that I wanted swapped. One had my real name on it. The other had a made-up-name and was the one I’d been using on a regular basis. It was also where all of my followers were.

Since I’m getting a start in freelancing, I decided to make my main account the one with my real name on it, and try not to ramble quite so much on it.

I first tried to do this a couple of weeks ago. I deleted the account with my name, and tried renaming the account with the made-up name to my name. Unfortunately, twitter told me the account was unavailable. I quickly re-created the account to avoid losing @benatkin, which is the same as my domain name.

Today, while I was filling out a request to twitter to change the names for me so I don’t lose them, an idea popped into my head. I tried it and it worked! Here’s what I did:

  • I went to the account settings on the benatkin account and changed the username to benjamin_atkin. I figured that if worse came to worse I’d still have some representation of my name.
  • I went to the account settings on the account with my made-up name (lowerCamelCase) and changed the user name to benatkin
  • I went to the account settings on benjamin_atkin (which used to be benatkin) and changed the username to lowerCamelCase.

Now, I don’t know if twitter thought this through, so I am calling this a “hack”. It may be that twitter just hasn’t implemented locking of old names after a rename, and would prefer that people like me go through customer service.

After it was done, I left a tweet to fill my followers in on the situation:

2245067457

I got Screenflow and a Snowflake with the intent to make screencasts, but found another use for them, that might be more valuable.

It started with me testing out my equipment. I wasn’t ready to do a scripted screencast, so I just coded for an hour, while talking, and looked at the results. I found that talking to myself out loud helped me figure things out more quickly in a couple of cases. And since I was testing my gear, talking to myself didn’t feel all that strange.

Some time after watching it, I wondered what it would be like to record myself frequently. Maybe if I did something really cool, I could take a look back and try to see what my thought process was, and it would reinforce it. Or, if I was in a slump, I could use it to remind myself what I’m capable of.

Then I asked myself whether it’s practical. The answer I got was a resounding “Sure it is!”. Space and processing power are cheap. With the default settings, Screenflow documents take roughly a gig an hour. 500 gigabyte hard drives can be had for under a hundred bucks. If I record 5 hours a day, which is a *lot*, it’s about a dollar a day for the space. Screenflow doesn’t take much processing power, or if it does, it doesn’t interfere with the work that I’m doing.

I’m not sure what the most clear analogy is to other fields, but there are obvious parallels. Disk Jockeys commonly record their experiments. Team sport coaches record their players’ performances.

I’m really excited about this. I can get part of the benefit of pair programming by talking out loud and learning from yourself, without the need for a willing partner. It’s also a journal that’s remarkably easy to write. It does take a lot of time to read, though, so I’ll probably only play back my favorite sessions, and I’ll only play bits and pieces of them most of the time.

The only caveat is I might feel like I’m my own big brother. I might as well get used to that, though, as I expect in the future there will be wearable video cameras that transparently archive everything. In fact, something like that’s probably already been built.

I still plan to do some screencasting. Stay tuned!

From the this-should-have-been-obvious department:

  • If there are a couple of friends whose tweets you feel like you can’t miss during the break, turn SMS updates on for them. That way you can stop checking twitter and still (hopefully) get their tweets quickly.
  • Log out of twitter.com on all desktop or mobile web browsers.
  • Do something to hide or log out of all desktop or mobile apps. Deleting accounts is fine, because they can always be recreated. Sure, I lose my cached data, but I don’t use a twitter client to store data, I use it to read the most recent updates. Here’s what I did for each of my twitter clients:
    • Nambu: I’ve been using this twitter client on my Mac for a couple of weeks. I like it. I was able to delete my account by finding the Accounts screen, selecting my account, and pushing the delete button. I also removed it from my dock.
    • Tweetie for iPhone: I use this on my iPod Touch sometimes, when I have wifi available. I had to enable multiple accounts in the settings before I could find a way to delete my account.
    • Twidroid: My Android twitter client. I couldn’t find a way to remove my username and password, so I just uninstalled it. I can install it later.
    • Syrinx: Ditto. Uninstalled it. (I used this OS X twitter client for months, but I’ve been liking Nambu better.)

In retrospect it would have been quicker for me to just change my twitter password.

The five-line sinatra app on http://www.sinatrarb.com/ is pretty damn impressive:

require 'rubygems'
require 'sinatra'
get '/hi' do
  "Hello World!"
end

I can do four lines better than that, though:

require 'sinatra'

So what does that get you?

batkin:cholla ben$ ruby -rubygems cholla.rb
== Sinatra/0.9.0.4 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.0.0 codename That's What She Said)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
127.0.0.1 - - [03/May/2009 10:13:46] "GET /index.html HTTP/1.1" 200 7 0.0019

A basic http file server, perfect for working with plain html, javascript, and CSS! Just create a public/ directory alongside the one-line sinatra app, and have at it! If you create an index.html file in public/, it will be served up when you go to http://localhost:4567/. Try it!

Once you decide to add some server-side code, you can simply go in to the sinatra app and add it.

On the microblogging site twitter, a blog post is called an update, or informally, a tweet. When someone copies a tweet and posts it to their twitter feed, it’s called a retweet. Sometimes opinions are retweeted by those who share them, other times it’s information, and other times it’s silly memes. This evening, a local friend of mine on twitter started a meme by saying “tweet.” and asking for a retweet. One person who retweeted it got his message retweeted.

retweets

I know I’m not the first person to graph retweets, but being curious as to what this particular graph would look like, I decided to do a graph in Python as a programming exercise. I did it using a GraphViz library. The code is here:

import pydot

graph = pydot.Dot('rt', graph_type='digraph')
tweeps = ('tysoncrosbie', 
           ('phxreguy', 
             ('sbowerman',
               ('phxwebguy', 'leaky_tiki'),
               'refriedchicken')), 
           'vhgill',
           'Yartibise')

def add_edge(source, dest):
  graph.add_edge(pydot.Edge(source, dest))

def first_flat(tree):
  if isinstance(tree, tuple):
    return first_flat(tree[0])
  else:
    return tree

def find_edges(tree):
  if isinstance(tree, tuple):
    source = tree[0]
    for dest in tree[1:]:
      add_edge(source, first_flat(dest))
      find_edges(dest)

find_edges(tweeps)
graph.write_png('rt_graph.png')

The code takes a nested list structure (a tree) and produces edges from it, which can be graphed by GraphViz. It uses pydot, a GraphViz library for Python. Here is the resulting image:

rt_graph1

Observations:

  • Python doesn’t have a built-in list flattening function. This was irritating. Ruby’s is Array#flatten. It would have been so much nicer to have been able to grab the first element of a flattened list rather than write the first_flat function or copy/paste a list-flattening function from the Internet.
  • pydot is really simple to use. I liked how it could produce a png file. I was planning just to have it create a dot file and then use GraphViz to create a png, but when I saw the write_png function I decided to just use that.
  • GraphViz has reasonable defaults. It produced a nice-looking graph on the first try. I think that’s a big part of why GraphViz is as popular as it is.

I was hoping to have a little more to show for tomorrow’s Python Interest Group meeting, but this will have to do!

I used to dread having to search backward in vim, because that meant scrunching my right pinky and ring finger next to each other to hit ?. So I remapped it. I used cc because I don’t use cc to change lines—I use S for that (it does the same thing). It’s much easier for me to hit cc than to hit ?, and since c is in the bottom row along with the / key it’s not hard for me to remember to use it.

The remapping is simple:

map cc ?.

After mapping this, I realized that the downside to having a funky vim setup is that I can’t have someone else who knows vim type in my window very easily. I am thinking of making pair and unpair commands that turn off and on my funky keymaps, respectively. Rather than duplicate the mapping code, I’ll just call unpair in my .vimrc file.

I am still using MacVim with my enter key mapped to escape. I use shift-enter or enter followed by o to insert multiple lines. I switched back to the normal setup for a while before realizing that the number of one-line inserts I make far outweighs the number of multiline inserts I make. I have found that is the best way for me not to have to reach for the esc key (I use ctrl all the time and have my caps lock key mapped to ctrl, so mapping caps lock to esc was out of the question).

I have ctrl-J and ctrl-K mapped to insert blank lines, and use them whenever I can remember to do so. I took the code from the Vim Tips Wiki, and switched the Ctrl for Alt in the remappings, so Ctrl inserts and Alt deletes. I use the command for inserting more than to deleting because I find it easy enough to just go down a line and hit dd than to remember to use a custom remapping.

Roughly two years after reading Snow Crash, I finally started reading Cryptonomicon. I’m really enjoying it so far. I can’t help but feel a little bit angry with myself for not reading it sooner, though. I really enjoyed Snow Crash, but after I finished reading it I didn’t immediately start on another Neal Stephenson book, but instead started on a book by another author. The other book wasn’t as exciting as Snow Crash, and it took me more time to read, and when I finally got done with it I had moved on to a different group of books, forgetting how much I enjoyed Snow Crash.

A couple of weeks ago, having lost interest in another book I was reading, I started carrying Snow Crash around with me. Two days ago I started reading it a second time. After I finished the first chapter, my interest in Neal Stephenson was re-kindled, and I picked up a copy of Cryptonomicon. And I am really enjoying it, and it’s helping me deal with stress.

I learned a couple of lessons from this experience:

  • I shouldn’t rely on passion alone to drive me to pursue my passions. Few, if any, pursuits are immune to distraction. Setting specific goals is important even when it’s for something I really want to do.
  • It doesn’t take long to rekindle a passion. If I’m feeling bored, and there’s something I remembered really wanting to do, but am considering putting off to pursue other interests, I can just try getting back into it for a short while. If my excitement returns, I can pursue that, rather than try to do other things I’m only mildly interested in. If not, I’ve only spent a small amount of time on it.

There’s no silver bullet to motivation, but it’s comforting to know that I’ve got a couple more tools in my motivational tool box.

In an earlier post, I said that I am no longer going to deny myself the pleasure of dabbling in different editors. It was my interpretation of the “use one editor; use it well” mantra I got from the pragmatic programmers. It was probably a misinterpretation of it. They also would recommend using the best tool for the job, and how can you know what the best tool for the job is without learning about all the alternatives? And, in the case of text editors, it’s practically impossible to know every one of them well enough to judge which is best.

One day I was feeling frustrated with vim, so I fired up emacs. I wanted to remind myself of one thing it has that vim lacks—the ability to view/edit a single buffer in multiple frames. Pretty nifty, really. If you’re unfamiliar with the terminology, in Emacs a frame is a top-level window (think JFrame), and a window is a split within a frame, or the whole frame if it isn’t split. In MacVim, each frame has its own vim instance with its own set of buffers, so you can’t view the same buffer in two different frames, which would be nice for having a big frame and a frame that can sit alongside other windows. In emacs it works without a hitch.

While I was in emacs, I noticed something else I like about it—the scratch buffer. In vim there’s a blank buffer that shows up when you start it, but it seems like vim would rather pretend it’s not there. If you delete a buffer, it closes any window (i. e. split view) that is associated with it, unless there is only one window in the frame, in which case it grudgingly shows the scratch buffer (or the last buffer if there’s another buffer still open).

I can think a couple of things that I gained from this experience. First, I can see that there are other developers who can sympathize with my experiences. If I ever get frustrated with vim, I can take refuge in the emacs community. Same for when I got frustrated with emacs and became a vimmer. Second, I was able to take the scratch concept and apply it to another part of my computing experience. I created a directory in my home directory called “scratch”. It’s going to be my new temporary working directory. I had one called sandbox but the name never quite felt right and I never got in the habit of using it.

I don’t know which editor I’ll be using a year from now. But for now, it’s vim, for the most part. I do want to try out SLIME and see how viable Viper-mode (vim emulation in emacs) is, though.