Newer Older

Walking Journal: 45 miles, starting a Twitter client chain

I've been neglecting both walking and posting on here, though I've neglected posting more, obviously.

I've been very busy with work and side projects and my house trying to fall apart on me, so I've been out of free time lately.

Anyway, my total is now up to 45 miles of walking. Not too much more than last time, really. I've gone on some walks around the neighborhood with Angie, and I'm not counting them, mostly because I don't know how long they are, really.

I decided I wanted to start a "chain," where every day I do something to work toward a goal I've set for myself (yes, I mean other than the walking, though that can be a chain as well).

Fortunately enough for me, I found Don't Break The Chain, where you can keep track of one or more "chains" of things you want to do every day.

The Twitter Client Chain

So I'm creating a web-based Twitter client, as a project for me to try out all the different techniques and technologies that I want to use, but don't have the chance to work with as much as I'd like during my day job. Also, ideally, it will at some point become a supplementary source of income.

That's a quite a way off until I have more free time in a month or two, but for now, I will satisfy myself with making some small amount of progress on it each day (hopefully).

I'm writing this client in Erlang, using the awesome Nitrogen web framework with the equally awesome MochiWeb web server. My goals for this project include using test driven development and continuous deployment and fully embracing the mantra of "release early, release often".

The plan is to have something up and running on a server as soon as possible. By something, I mean even less than a full-featured twitter client. But as soon as something is up, I can start getting feedback, and see what I should work on next. If I'm creating a product for users, there's no use in developing what I want.

I need to develop what my users want.

I started this chain up about a week ago, and broke it after the first day. Now I'm trying again.

Tests and pre-commit hooks

During my previous, one-day chain, I managed to get a test harness (using the EUnit Erlang unit test framework) set up which will find any modules ending with _tests, stopping at the first error.

At the moment, I have a shell script which runs the tests. When it starts to take too long, I will switch over to an Erlang module which loops through, so I don't get the startup times of the Erlang interpreter for each test. Or if anyone knows an easier way (perhaps there's already a module that does that somewhere?).

    #!/bin/bash

for modfile in `ls ebin/*_tests.beam`
do
mod=`basename $modfile .beam`
echo Running $mod:
erl -noshell -pa ./ebin -s runtest main ${mod%.*}
[ $? -eq 0 ] || exit 1
done
[ $mod ] || exit 1

The runtest module consists of the following:

    -module(runtest).
-export([main/1]).

main(Mod) ->
case eunit:test(Mod) of
error -> halt(1);
_ -> init:stop()
end.

It's all kind of thrown together, but the point is incremental improvement, so I'll get back to it when/if I need to. Like I said, there's probably something else out there that will do a better job at this than I did.

So, today, my "chain link" was partially taking that script and setting it up to run from the GIT pre-commit script, and partially writing this blog post.

Getting it set up to run as a pre-commit script just involved making sure it returns non-zero whenever there is a test error (or if no tests were run, which happens when make hasn't been run yet).

The pre-commit script itself (placed in .git/hooks/pre-commit and set executable) is pretty simple:

    #!/bin/sh
./tests.sh
if [ $? != 0 ]
then
echo "===================================="
echo " Commit stopped due to test failure"
echo "===================================="
exit 1
fi

Chain length: 1!

What's next?

Next up, I'm acutally going to start on the meat of the project. Since I haven't fully decided on what GUI library I want to use, nor what GUI testing framework I want to use, I'm going to start on the backend with code to manage user login info and queries (timeline searches, DMs, etc.).

I've got some great ideas (I think) on ways to enhance the way people have conversations over Twitter (and eventually other mediums), so you can be sure that there will be more posts about this in the future.

blog comments powered by Disqus