How to never EVER lose your phone contacts again

By , July 30, 2011 8:31 pm

It continually astonishes me how often I see facebook status updates / group invites / tweets / emails from friends and acquaintances saying something to the effect of “ARGH my iPhone / Blackberry / Nokia phone has been stolen / lost / eaten by my pet donkey and I lost everyone’s numbers, please can you all send me your numbers!!”

People, it’s 2011 already! Whilst technology is still far from perfect, it landed a man on the moon 42 years ago way before mobile phones existed, and certainly solved this particular problem of disappearing phones several years ago.  So for those of you who still haven’t figured this out, without further ado I will outline a solution which should only cost 10 minutes of your life and ensure you never have to broadcast a panicked message cursing your pet donkey and asking everyone to send you their numbers.

Continue reading 'How to never EVER lose your phone contacts again'»

Share

email nirvana

By , May 15, 2011 4:33 pm

Back in November 2010 I blogged about how I was chasing my dream of catching up on all personal mail, by automatically measuring my progress. Well, it worked – I finally made it!  For the first time in years, I finally have an empty inbox.  It turns out Google even hid a little Easter egg in gmail to reward people who reach this state of bliss:

This feels good.  Next up is to purge my massive TODO list of out of date entries and then re-evaluate what’s left …

Share

measuring email inbox sizes

By , November 28, 2010 6:35 pm

Like many people, for a long time I have been drowning in email. I am perhaps bit unusual in that whilst my personal google inboxes are permanently overflowing, my work inboxes are generally very close to empty. This is because as a (bad) practitioner of GTD and sometime reader of Inbox Zero and similar sites, I do actually know how to get grips with email, and through professional pride apply the techniques fairly religiously when I’m working. In contrast, when it comes to dealing with personal mail, I’ll always favour procrastinating on some other interesting project instead. God forbid I should ever get my personal life in gear!

Well, this bad habit has been stressing me out for a LONG time now. I’m a long-term fan of Gretchen Rubin’s Happiness Project, and the other day stumbled across one of her older posts entitled Measure what you want to manage. I’d been wanting to graph the size of my inboxes over time, to get some grip on how bad my backlog actually is, and her post gave me the nudge to actually sort it out.

As usual, Ruby makes it almost ridiculously easy. There’s a beautiful written gem called gmail which uses IMAP to talk to your gmail account. So then it’s just a matter of writing a little program to append a line of gmail folder sizes to a CSV file every time it gets run:

#!/usr/bin/env ruby

require 'pathname'
require 'rubygems'

# sudo gem install gmail
# Note: this is an improved version of Daniel Parker's ruby-gmail
# http://rubydoc.info/gems/gmail/0.3.4/frames
require 'gmail'

# sudo gem install fastercsv
require 'faster_csv'

USERNAME = 'your.account.name.goes.here@gmail.com'
PASSWORD = 'your.password.goes.here'

CSV_FILE = Pathname(ENV['HOME']).join(
  "choose", "a", "path", "to", "gmail-counts.csv"
)

labels = FasterCSV.open(CSV_FILE, 'r').shift[2..-1]

FasterCSV.open(CSV_FILE, 'a') do |csv|
  Gmail.connect(USERNAME, PASSWORD) do |gmail|
    now = Time.now
    counts = [ now.to_i.to_s, now.strftime("%Y/%m/%d.%H:%M:%S") ]
    labels.each do |label|
      unread = label.gsub!(/ unread$/, '')
      folder = gmail.mailbox(label)
      count = unread ? folder.count(:unread) : folder.count
      puts "%s: %d (%d unread, %d read)" % \
        [ label, count, folder.count(:unread), folder.count(:read) ]
      counts << count
    end
    csv << counts
  end
end

Then create gmail-counts.csv in the folder referenced in the script, whose header line contains a list of the labels you want counted (append unread if you want the unread count rather than the total, and prefix “special” gmail folders with [Google Mail]/. Here’s an example of the header followed by a single line of folder counts:

epoch,datetime,INBOX,INBOX unread,[Google Mail]/Drafts,music
1290873125,11/27/2010.15:52:05,555,20,12,1596

Then make sure the program is automatically run on a regular basis somehow. On Linux this is as simple as adding a new line into your crontab. My quietrun utility comes in handy for this:

0 6,12,18 * * * quietrun /path/to/script/count-gmail

Then you can use Google Docs or your favourite spreadsheet / charting application to plot some nice graphs. I used this script which is written in the Ploticus graphing language; here is the result:

sample graph of gmail inbox size over time

Easy!

UPDATE 5 months later! (15th May 2011): I finally made it!

Share

Maven fail

By , October 7, 2010 8:18 pm

In my recent work I have encountered Apache Maven, and I think the following snippet of real-world Maven code nicely sums up why Maven is not the idea replacement for the horror that is ant:

  <profiles>
    <profile>
      <id>unix</id>
      <activation>
        <os>
          <family>unix</family>
        </os>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>set-run-file-perms</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>chmod</executable>
                  <arguments>
                    <argument>0755</argument>
                    <argument>${project.build.directory}/foo.sh</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

Dear god. 34 lines and a plug-in, just to change the permissions on a file in a platform-specific way??

I should add that the above was written by an extremely smart guy who is a top-notch programmer; no, I don’t think the author is at fault here. Even if there’s a more concise/portable way of achieving the same result in Maven (and there might well be – I admit I’m still a Maven newbie), there’s still the undeniable fact that XML is horrendously verbose, and any code written in it is by nature unnecessarily difficult to maintain. To this end I applaud the ongoing efforts supporting the use of YAML to implement the Maven POM.

It’s worth seeing what the above would look like if we wrote it in rake:

require 'pathname'

desc "Make binary executable"
task :chmod do
  File.new(Pathname.new(build_dir) + "foo.sh").chmod(0755)
end

I don’t think I need to make a case for which is more legible or maintainable. Oh, and the Ruby version is cross-platform.

To continue an anti-XML rant which has been made countless times already: what the ant and Maven people don’t seem to realise is that XML is not a real programming language and is therefore not expressive enough to deal with many cases that a build system needs. The clue’s in the name, guys! “M” is for “markup” not “Turing-complete“. That’s why every time you need to do something vaguely unusual for which there isn’t an ant taskdef or Maven plugin, you have to write hundreds of lines more Java/XML just to cope with that case. That’s why Maven needs so many damn plugins.

The accidental silver lining to this is that because it takes so much effort to accomplish simple tasks, Maven developers find themselves compelled to reuse and share plugins, and to be fair, Maven has some good ideas on how to do this, even if the implementation isn’t always the best. For example, the built-in plug-in repository management and plug-in dependency management seem to work nicely, but unfortunately for some reason it has a propensity to download plug-ins on most runs, far more frequently than any sensible caching layer should.

DSL issues aside, I’m not convinced by the fixed lifecycle philosophy behind Maven either. I wonder if it was borne out of frustration with the lack of proper dependency checking in ant.

That said, I do like how Maven encourages standardization of the build lifecycle and phase namespace thereof, since newcomers to a project immediately know some familiar entry points. But the same could be said of 99% of projects which use Make and use standard rule target names such as install and clean. And I suspect that many developers suffer when they try to shoe-horn their own project’s build requirements into Maven’s standard lifecycle.

My concern with this phased approach is that it is too linear.  The expectation is that a build process is a one-dimensional sequence of steps, and you get to choose your starting point but not much else.  This seems fundamentally wrong to me.  A build dependency tree is well understood to be a DAG, and any build system which doesn’t model this properly seems to me to be burying its head in the sand.  On the other hand, if it does model it properly, which includes implementing proper dependency resolution, the required build lifecycle should emerge naturally without having to dictate that generate-sources comes before compile which comes before test and so on.

I’ve had some ideas of what the ideal build system looks like, and how to get there from the conventional Java world. More on that soon.

Share

announcing rypper (again)

By , May 20, 2010 10:54 pm

Back in August 2009, I announced the release of a simple script called rypper which I wrote to wrap around zypper and provide the ability to make batch operations on repositories. Here are some example usages:

# list all disabled repos
rypper -d

# list all enabled repos with autorefresh off
rypper -e -R

# list all repos which have anything to do with KDE
rypper -x kde

# list priority and URIs for all repos whose alias contains 'home:'
rypper -a home: l -pu

# enable autorefresh on all OpenSUSE Build Service repos
rypper -u download.opensuse.org -R mr -r

# remove all repos on external USB HDD mounted on /media/disk
rypper -u /media/disk rr

I only got one response so I assumed it wasn’t that useful to other people.

However here I am at BrainShare EMEA in Amsterdam surrounded by like-minded geeks, and in a fit of enthusiasm / procrastination, I have finally got round to learning how to build openSUSE Build Service packages, and so proudly (?) present my first OBS package release: the 1-click install version of rypper. Enjoy!

UPDATE 21 March 2011: based on feedback from SLE Product Management, I have submitted a formal request to have zypper extended to include this kind of functionality.

Share

Panorama Theme by Themocracy