Filed under Productivity

My Brain on Information

I’ve read two things recently that have made me think about and reconsider the role of information in our lives and particularly the way in which I consume and process it. We live in an information-dense era of human history. In the western world (and increasingly, the world in general) the tools to access, consume, produce and distribute vasts amounts of information are available to almost everyone at just a moments’ notice. In many ways, we are living in a Golden Age of Information. The problem is, this Golden Age first crept up on us stealthily and then rammed into us headlong at full speed. As a result I think most of us, even those considered “digital natives” (myself included), seem to be perpetually ill-equipped to deal with both the challenges and opportunities of an increasingly information-rich existence.

Last week I read Accelerando, a set of short stories by British science fiction author Charlie Stross. The stories start from the near future (almost the present) and extend to a distant post-Singularity future where humanity lives among the stars, but in the shadows of godlike intellects. Though the entire collection is worth reading (and available for free), the first few stories about a world not too different from our own were particularly interesting. At one point one of the main characters, a very intelligent serial entrepreneur (and “venture altruist”) name Manfred Macx claims to consume a megabyte of text and several gigabytes of multimedia a day just to keep current.

That’s a lot of information for any person to consume in a day – a megabyte is roughly half a million English words. Though this is science fiction, I think we’re quickly getting to the point where people who want to stay current with the pace of science and technology will be required to consume enormous amounts of information regularly. Half a million words a day may be too much for an unaugmented human (Macx has an array of cybernetic implants and software agents forming a “exocortex” for information processing) but I think tens of thousands of words a day will soon become par for the course. And that’s just text. I’m not including understanding diagrams, source code, operations manuals or even video or audio. If we’re supposed to be assimilating such huge quantities of information on a regular basis how are we supposed to make sense of it all?

That brings me to a piece on The Atlantic website dramatically titled “Is Google Making Us Stupid?“. It’s about how the use of search engines and similar fast information retrieval systems is supposedly rewiring our brains. While some parts of the piece are overly sentimental and melodramatic, the core point is sound: the tools we have access to and the way we use them plays a role in shaping the functionality of our brains. I also sympathize that a habit of continually sampling little bites of information can be deeply unsatisfying. It’s easy to get hooked on to a Facebook or Twitter stream but as you stay hooked you can feel your brainpower wither as you lose the ability to concentrate longer than 140 characters. When I get stuck on Hacker News or Reddit for hours I feel terrible by the end of the day. Though I love good stories and movies it’s easy to get hooked on Netflix, passively consuming information but not really doing anything. But I’d like to believe that we can train our brains to be not quite so helpless in the face of endless streams of juicy tidbits.

A growing body of research is showing that the human brain is an incredibly flexible organ. Neuroplasticity is the norm, not the exception. As the amount of information we need to process increases (and our tools to do so get better) our brains change to accomodate it all. That of course begs the question: how far can we push ourselves? Can we train our brains to not just flit from hyperlink to hyperlink but actually digest and understand large amounts of interconnected material with greater efficiency and accuracy? Can we ensure that Google makes us smarter and wiser, not stupider?

Though our reading habits (and by extension our general thought patterns) might be changing, the change is not accidental nor is it inevitable. Instead of bemoaning the loss of the slow reading habits of yesteryear I think we should be trying to embrace the information-dense world around us. In particular, we need to stop thinking of deep reading and skimming as antagonistic to each other. Perhaps what we need to do is not to read slower, but rather separate the physical act of reading from the mental act of comprehending what we have read. I would love to be able to read text fast, look up links and references and then let the mass of information “ferment” in my brain. I’d like to be able to train my brain to think of what I’ve read after I’m done looking at the text forming connection betweens concepts and ideas while I’m walking down the street or taking a shower.

Perhaps this is an exceedingly computer-science centric way of thinking about the brain and thought processes. To be honest, I’ve been writing code and processing data algorithmically far longer than I’ve been learning about how the brain works. I do tend to think of the brain primarily as an information processor. Unlike the author of The Atlantic article I’m not nearly as attached to the so-called “human” aspect of my intelligence (but that’s a matter for another blog post). I like settling down with a cup of coffee and a good book in a nice armchair as much as the next guy, but only on the weekends. During the week I’d like to come up with six impossible things before breakfast and figure out how to make them possible through the course of the day. To do that I need to keep the information machine fed, creativity doesn’t happen in a vacuum. I’d love to know how to do that better.

Show Git information in your prompt

I’ve been a sworn fan of version control for a good few years now. After a brief flirtation with Subversion I am currently in a long term and very committed relationship with the Git version control system. I use Git to store all my code and writing and to keep everything in sync between my machines. Almost everything I do goes into a repository.

When I’m working I spend most of my time in three applications: a text editor (generally Emacs), a terminal (either iTerm2 or Gnome Terminal) and a browser (Firefox or Safari). When in Emacs I use the excellent Magit mode to keep track of the status of my current project repository. However my interaction with git is generally split between Emacs and the terminal. There’s no real pattern, just what’s easiest and open at the moment. Unfortunately when I’m in the terminal there’s no visible cue as to what the status of the repo is. I have to be careful to run git status regularly to see what’s going. I need to manually make sure that I’ve committed everything and pushed to the remote server. Though this isn’t usually a problem, every now and then I’ll forget to commit and push something on one of my machines, go to another and then realized I’ve left behind all my work. It’s annoying and kills productivity.

Over the last few days I decided to sit down and give my terminal a regular indicator of the state of the current repository. So without further ado, here’s how I altered my Bash prompt to show relevant Git information.

Extracting Git information

There are generally three things I’m concerned about when it comes the Git repo I’m currently working on:

  1. What is the current branch I’m on?
  2. Are there any changes that haven’t been committed?
  3. Are there local commits that haven’t been pushed upstream?

Git provides a number of tools that gives you a lot of very detailed information about the state of the repo. Those tools are just a few commands away and I don’t want to be seeing everything there is to be seen at every step. I just want the minimum information to answer the above question.

Since the bash prompt is always visible (and updated after each command) I can put a small amount of text in the prompt to give me the information I want. In particular my prompt should show:

  1. The name of the current branch
  2. A “dirty” indicator if there are files that have been changed but not committed
  3. The number of local commits that haven’t been pushed

What is the current branch?

The symbolic-ref command shows the branch that the given reference points to. Since HEAD is the symbolic reference for the current state of the working tree, we can use git symbolic-ref HEAD to get the full branch. If we were on the master branch we would get back something like refs/heads/master. We use a little Awk magic to get rid of everything but the part after the last /. Wrapping this into a litte function we get:


function git-branch-name
{
    echo $(git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'})
}

Has everything been committed?

Next we want to know if the branch is dirty, i.e. if there are uncommitted changes. The git status command gives us a detailed listing of the state of the repo. For our purposes is the very last line of the output. If there are no outstanding changes it says “nothing to commit (working directory clean)”. We can isolate the last line using the Unix tail utility and if it doesn’t match the above message we print a small asterisk (*). This is just enough to tell us that there is something we need to know about the repo and should run the full git status command.

Again, wrapping this all up into a little function we have:

function git-dirty {
    st=$(git status 2>/dev/null | tail -n 1)
    if [[ $st != "nothing to commit (working directory clean)" ]]
    then
        echo "*"
    fi
}

Have all commits been pushed?

Finally we want to know if all commits to the respective remote branch. We can use the git branch -v command to get a verbose listing of all the local branches. Since we already know the name of the branch we’re on, we use grep to isolate the line that tells us about our branch of interest. If we have local commits that haven’t been pushed the status line will say something like “[ahead X]“, where X is the number of commits not pushed. We want to get that number.

Since what we’re looking for is a very well-defined pattern I decided to use BASH’s built-in regular expressions. I provide a pattern that matches =”[ahead X]” where X is a number. The matching number is stored in the BASH_REMATCH array. I can then print the number or nothing if no such match is present in the status line. The function we get is this:

function git-unpushed {
    brinfo=$(git branch -v | grep git-branch-name)
    if [[ $brinfo =~ ("[ahead "([[:digit:]]*)]) ]]
    then
        echo "(${BASH_REMATCH[2]})"
    fi
}

The =~ is the BASH regex match operator and the pattern used follows it.

Assembling the prompt

All that’s left is to tie together the functions and have them show up in the BASH prompt. I used a little function to check if the current directory is actually part of a repo. If the =git status= command only returns an error and nothing else then I’m not in a git repo and the functions I made would only give nonsense results. This functions checks the =git status= and then calls the other functions or does nothing.

function gitify {
    status=$(git status 2>/dev/null | tail -n 1)
    if [[ $status == "" ]]
    then
        echo ""
    else
        echo $(git-branch-name)$(git-dirty)$(git-unpushed)
    fi
}

Finally we could put together prompt. BASH allows for some common system information to be displayed in the prompt. I like to see the current hostname (to know which machine I’m on if I’m working over SSH) and the path to the directory I’m in. That’s what the \h and the \w are for. The Git information comes after that (if there is any) followed by a >. I also like to make use of BASH’s color support.

function make-prompt
{
    local RED="\[033[0;31m\]"
    local GREEN="\[033[0;32m\]"
    local LIGHT_GRAY="\[033[0;37m\]"
    local CYAN="\[033[0;36m\]"

    PS1="${CYAN}\h\
${GREEN} \w\
${RED} \$(gitify)\
${GREEN} >\
${LIGHT_GRAY} "

}

Conclusion

I like this prompt because it gives me just enough information at a glance. I know where I am, if any changes have been made and how much I’ve diverged from the remote copy of my work. When I’m not in a Git repo the git information is gone. It’s clean simple and informative.

I’ve borrowed heavily from both Jon Maddox and Zach Holman for some of the functionality. I didn’t come across anyone showing the commit count, but I wouldn’t be surprised if lots of other people have it too. There are probably other ways to get the same effect, this is just what I’ve found and settled on. The whole setup is available as a gist so feel free to use or fork it.

Tagged , ,

Where is the computation?

I’m pretty happy with my Nexus S so far. It’s a decent phone with some solid apps and services. More importantly, it’s a well-equipped little pocket computer. However the more I use smartphones (and similar devices like the iPod Touch) the more I feel a nagging sense that I’m not really these devices well, at least not to their full potential.

While the devices in our pockets might be increasingly powerful general purpose computers I feel like we use them more for communication than for computation. That’s not to say that communication does not require computation (it does, lots of it), but we’re not using our devices with the goal of solving problems via computation.

This is perhaps a very programmer-centric viewpoint of mobile technology, but one that is important to consider. Even someone like me, who writes code on a regular basis to solve a variety of both personal and research problems, does very little computation on mobile devices. In fact, the most I’ve been using my Nexus for is email, RSS reading, Twitter, Facebook and Foursquare. While all those services definitely have good uses, they are all cases where most of the computation happens far away on massive third-party datacenters. The devices themselves act as terminals (or portals if you prefer a more modern-sounding term) onto the worlds these services offer.

Just to be clear, I’m not saying that I want to write programs on these devices. Though that would certainly be neat, I can’t see myself giving up a more traditional computing environment for the purposes of programming anytime soon. However, I do want my device to do more than help me keep in touch with my friends (again, that’s a worthy goal but just the beginning). So the question is, what kind of computation do we want our mobile devices to do?

Truth be told, I’m not entirely sure. One way to go is to have our phones become capable personal assistants. For example, I would like to be able to launch an app when I walk into a meeting (or better yet, have it launch itself based on my calendar and geolocation). The app would listen in on the conversation, apply natural language processing and generate a list of todos, reminders and calendar items automatically based on what was said in the meeting. Of course there are various issues (privacy, technology, politics, corporations playing nicely with each other) but I think it’s a logical step forward.

As payment systems in phones become more popular, I’d like my phone to become my banker too (and I’m not just talking about budgeting and paying bills on time). For example if I walk into a coffee shop my phone should check if I’m on budget as far as coffee shops go and check coffee shops around the area to suggest a cheaper (or better, for some definition of better) alternative. And it doesn’t just have to be limited to coffee shops.

Mobile technology is sufficiently new that most of us don’t have a very clear idea of what to do with it (or a vision of what it should do). Most so-called “future vision” videos focus more on interfaces than actual capabilities. However this technology is evolving fast enough that I think we’re going to see the situation improving quickly. With geolocation-based services, NFC and voice commands becoming more ubiquitous and useful the stage is becoming set for us to make more impactful uses of the processors in our pockets. As a programmer I would love to be able to hook up my phone to any cloud services or private servers I’m using and be able to interact with them. The mobile future promises to be interesting and I’m definitely looking forward to it.

Tagged ,

Beat Procrastination with Science

Another day and another poor soul on Hacker News grieving about losing the day to procrastination. I’ve been there, done that. Too many times to count. And I’ve heard the story retold in many variations. But the one thing that struck me about this particular story was that the author says, “I’ve still no clue why humans procastrinate (sic).”

Now that strikes me as strange because it’s not like procrastination is some deep mystery of the universe. There are people who actually study procrastination and why humans do it (and by extension, how to fight it). They’re called scientists, more accurately, neuroscientists and psychologists. What’s even better is that someone else has gone and done the work of curating much of the available research in the area and tried to offer a coherent, scientific strategy for beating procrastination. That article (and the references) are a veritable treasure trove of information, but here’s the quick start version to get you up and fighting procrastination right now.

Essentially beating procrastination comes down to three steps:

1. Increase your expectancy of success

Do this by starting properly on small tasks that you can finish easily. This helps to build success spirals where one victory gives you the mental boost to make it to the next. Join groups (like Toastmasters) and create situations that will improve your chance of success. Visualize your goals but be honest about your current situation so that you can plan a realistic strategy to what you want.

2. Increase value

Engage in tasks that are meaningful to you and provide you with ample opportunities for entering a state of flow. Reduce errands and other short, distracting tasks so that you can focus on the things that really matter to you.

3. Control impulsiveness

Set clear and frequent goals. Measure repeatedly and correct course accordingly. Acknowledge that humans are creatures of habits and set ones that are biased towards putting you in a favorable position to get work done.

In conclusion

The breadth and depth of human knowledge can be very surprising, especially when it comes to knowledge about yourselves. If you ever catching yourself saying “I don’t know why I do this” consider the possibility that someone else does know (and has published about it). Science and rationalities can be powerful allies when we are our own worst enemies.

Sunday Selection 2011-12-11

Around the Internet

More shell, less egg It’s alway a joy to see two masters at the top of their craft engaged in a respectful, but determined duel. This is a short commentary on Donald Knuth and Doug McIlroy’s approaches to literate programming. Worth reading even if you’re not a big fan of literate programming.

Selective use of technology I firmly believe that science and technology is a good thing and that our world is better because of them. However I also understand that technology cannot do everything for us. In particular there are a lot of decisions it cannot make for us (yet). I also tend to get a lot of my best work when I am least partially disconnected and can hold at bay the full force of the Internet. All things in moderation.

Why sugar makes us sleepy (and protein wakes us up) As much as many of us would like to live as if we disembodied brains surviving on anything that barely resembled food, that is definitely not the case. Since we are stuck with our flesh-and-blood physical bodies for the foreseeable future, it is a good idea to figure out how it all works and make the most of it.

From the Bookshelf

Do the Work While I’m not entrely a fan of Steven Pressfield’s use of vaguely “spiritual” ideas and terms, this book is still worth reading for everyone. It’s especially useful if you have that big project you’ve been thinking about but never got around to actually starting. At $1.99 for the Kindle edition, it’s a steal.

Video

What we actually know about software development Despite the importance of software development, most developers are acutely unaware of the scientific studies in the area and rely mostly on anecdote. Luckily there is an increasing amount of research in software development (not to be confused with computer science) and it’s worth knowing what we actually know about the field and what is myth.

Tagged , , , ,
Follow

Get every new post delivered to your Inbox.

Join 331 other followers