Fork me on GitHub

Sigil.org Blogging about technology, beer, and whatever the hell I want

26Jan/120

Twilio + Trello = Twellio

Posted by sarumont

Shortly before the end of 2011, the intrepid developers over at FogCreek Software released a new, free product called Trello. Trello is, at its core, a pretty simple idea: collaborative list management. The end result, however, is a great product that solves many issues from collaborative discussions to brainstorming to TODO lists.

Walking home one day early this month, I had a thought I wanted to capture in my Trello TODO board. Now, Trello works well enough in my smartphone's browser, but sometimes that is a bit heavy to use. "What if," I thought, "I could send a text message to Trello?!" And thus, Twellio was born.

Out of sheer happenstance, I checked my Google Reader that night and saw the first Twilio developer contest of 2012: an app for DOers. I hacked Twellio together over the next couple weeks, and it's now functional. Combined with the Direct SMS widget found in Android Ice Cream Sandwich, capturing items on my Trello board is very quick.

I've been working on a side project written in django for awhile now, so I naturally started this project in the same framework. I've been enjoying Python immensely, especially faced with the verbosity of Java on a daily basis.

A library for interacting with Twilio via Python already exists, but Trello was so new there was no such thing. When I started hacking on Twellio, there was no public API yet. I began py-trello reverse-engineering the (mostly) RESTful URLs from using Trello. Shortly thereafter, work on the Trello Public API began. I've since switched py-trello to use the real API and plan on keeping it up to date as best I can. If you're interested in features, I've created a Trello board to track features, discussions, etc.

For now, Twellio is available for free. I may add features and create a paid version later on, but I don't want to build a second product simultaneously. If you have any comments, questions, suggestions, etc., please head over to the Twellio board to discuss.

Cheers!

27Apr/110

CODE: A review four years in the making

Posted by sarumont

According to Amazon, I bought CODE by Charles Petzold in September of 2007. After reading about the book on a blog I have long since forgotten, I added it to my Amazon Wish List. It languished there before eventually being used to pad my cart for Free Super Saver Shipping on that fateful September day almost four years ago.

I remember starting to read CODE on a flight for a business trip. Through the first chapter, I was intrigued. Moving into chapters two through four, I was fondly recalling my favorite section in Boys' Life magazine - Codemaster. By chapter ten, however, I was back in a classroom at Southern Poly, proving for the third time I knew how to convert from base-10 to binary and derive truth tables for circuits with my eyes closed.

CODE then took up space on my bookshelf, in a moving box and on the same bookshelf in an apartment about 375 miles north of its previous home. As I have been travelling down the road of minimalism, clearing my bookshelf has been closer to the process end than the task end. Stumbling across CODE, I decided to move it to the queue that is my nightstand. It has taken up space there until I picked it up tonight and flipped to chapter 14, marked by an American Airlines ticket stub from a business trip long ago.

"Tonight?" you ask. "How can he be writing this review TONIGHT?! There are ten more chapters to read!" Well, I made it through about a page of chapter 14 and skimmed the rest. The remaining pages in the book will not change my mind about it. The verdict? Haven't you guessed that already?

In my college career, I had no less than three courses where I was expected to learn various binary operations (conversion from decimal, two's complement, etc.), Boolean algebra, basic and advanced logic gates (and truth tables to go with!). Am I jaded? Sure, but I don't think my viewpoint would change had I only had one of those courses. As a programmer, I know all of this stuff. Some of it, I deal with daily; the rest of it, I avoid like the plague. Either way, the knowledge is in my brain, lodged somewhere deep between the name of that actress in that movie and the kid that spilled his drink on my lap in the lunchroom in middle school.

Is CODE a bad book? Should the grammar Nazis (myself included) be after Petzold with pitchforks? Would copies of the book be better suited to fuel for a bum's barrel fire than reading? Hell no. Petzold weaves a marvelous tale in the beginning to hook you, and his style continues throughout the book to make some pretty intense (to the uninitiated) material easy to grasp.

My bitterness toward the book is born purely from the fact that the blog recommendation which prompted me to purchase it in the first place was a coding blog. I cannot understand, however, why any seasoned programmer would want to read it.

Who is the book for? The ideal place for it is in a computer science survey course. The material and depth thereof is perfect for letting people know what they'll be getting into (at least in some CS curricula). Obviously, the other ideal audience is the non-programmer - writers, techies, mechanics, significant others and parents of geeks and coders. THESE people would enjoy at least the first half of the book.

I'm glad to have finally completed the book; I hope my copy will find a loving home, as it will soon be making space on my bookshelf for something more to my tastes.

Filed under: coding No Comments
2Sep/100

Twice the bits, twice the time

Posted by sarumont

When I built a zfs-based RAID array last year, I switched to the 64-bit build of FreeBSD. Knowing that 64-bit software is inherently evil, I set up a 32-bit jail for coding. At some point, I was dragged into doing UI work requiring GWT's devmode. I took the easy way out - abandoning my jail. Comparing compile-time numbers to a new machine a colleague built yesterday, it occurred to me to try a 32-bit JDK.

My work revolves around our codebase and our customer's codebase. Both are architected in a very minimalistic fashion, using ant to build. There are a couple xjc tasks, some javac annotation preprocessing and some code generation, but the bulk of the build process is pure javac. I'll shutup now; you're here for the numbers. Here they are ('real' time from time:

64-bit OpenJDK 6 b20, FreeBSD 8.1-STABLE

Codebase 0:


18.36 real
17.59 real
17.57 real
18.60 real
17.97 real
------------
(avg: 18.02)

Codebase 1:


23.06 real
23.37 real
22.34 real
22.64 real
22.34 real
------------
(avg: 22.75)

32-bit OpenJDK 6 b20, FreeBSD 8.1-STABLE

Codebase 0:


12.99 real
13.64 real
12.77 real
12.38 real
12.42 real
------------
(avg: 12.84)

Codebase 1:


15.35 real
15.44 real
15.20 real
15.17 real
15.14 real
------------
(avg: 15.26)

Compiling with a 64-bit javac is 140% and 149% SLOWER than the 32-bit javac. Roughly 1.5x! How much time have I wasted compiling with a 64-bit javac during the last year? I don't want to approximate that math. If I worked in a real office, I'd have a reason for compiling with 64-bit javac. Needless to say, JAVA_HOME has already been changed.

If there's a more general point to be had here, it would be that those extra bits can indeed affect performance in a human-perceivable and negative fashion. Always be sure to evaluate your tools to
determine where you are wasting time.

15Mar/102

Backups with ZFS and Amazon’s S3

Posted by sarumont

Amazon's S3 provides unlimited, relatively cheap storage, accessible via HTTP (using REST/SOAP). This is ideal for personal offsite backups. The barrier to entry is low as are the costs.

Sun's ZFS turns everything you know about managing filesystems on its head. When I recently upgraded my storage array, I decided to load my machine with extra RAM for ZFS rather than buying a dedicated RAID card. One of the best features of ZFS is the low-cost snapshots. You can snapshot a filesystem, and said snapshot will not take any space on disk until the original is modified. To put it another way, the snapshots only store the (block-level) diffs.

The icing on the snapshot cake is the ability to send a snapshot as a stream. This can be piped over the network (i.e. ssh) or simply output to a file (then bzipped and uploaded to S3!). ZFS also allows you to send a differential of two snapshots.

To put this into action, I have written a script which will create a snapshot, bzip it, encrypt it and upload it to S3. I use a threshold to determine whether I should upload the full or incremental to save space/bandwidth (and time, as my cable upstream isn't that great...). To interface with S3, I'm using s3tools.

I realized afterward that s3tools have GPG encryption built in, but I think it is simpler to use openssl and a passphrase for this use-case.
Here's the script:

#!/bin/sh
#
# Copyright 2010 Richard Kolkovich. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY Richard Kolkovich ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Richard Kolkovich OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those of the
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Richard Kolkovich.
#
ZFS=/sbin/zfs
BZIP=/usr/bin/bzip2
OPENSSL=/usr/bin/openssl
MD5=/sbin/md5
S3CMD=/opt/s3cmd/s3cmd
BACKUP_DIR=/tank/backup
TEMP=$BACKUP_DIR/tmp
PASSFILE=$BACKUP_DIR/.password
if ! test -d $TEMP; then
    mkdir $TEMP
fi
# Backup a given zfs store
# arguments: name, zfs fs, threshold (0 to always use incremental), S3 bucket
backup() {
    NAME=$1
    FS=$2
    THRESHOLD=$3
    BUCKET=$4

    # incremental
    SNAP=$FS@incremental
    SUFFIX=incremental
    $ZFS destroy $SNAP
    $ZFS snapshot $SNAP
    $ZFS send -i $FS@full $SNAP > $TEMP/$NAME
    export BLOCKSIZE=1024
    SIZE=$(( `du $TEMP/$NAME | awk '{print $1}'` * 1024 ))

    if test $THRESHOLD -eq 0 || test $SIZE -gt $THRESHOLD; then
        rm $TEMP/$NAME
        $ZFS destroy $SNAP
        SNAP=$FS@full
        SUFFIX=full
        $ZFS destroy $SNAP
        $ZFS snapshot $SNAP
        $ZFS send $SNAP > $TEMP/$NAME

        # a new full invalidates old incrementals
        $S3CMD del s3://$BUCKET/$NAME-incremental.bak
        $S3CMD del s3://$BUCKET/$NAME-incremental.bak.md5
    fi

    # compress
    $BZIP $TEMP/$NAME
    FILE=$TEMP/$NAME.bz2

    # encrypt snapshot
    $OPENSSL enc -aes-256-cbc -salt -pass file:$PASSFILE -in $FILE -out $FILE.bak
    rm $FILE
    FILE=$FILE.bak
    $MD5 $FILE > $FILE.md5

    # send snapshot to S3
    $S3CMD put $FILE s3://$BUCKET/$NAME-$SUFFIX.bak
    $S3CMD put $FILE.md5 s3://$BUCKET/$NAME-$SUFFIX.bak.md5

    # clean up
    rm $FILE
    mv $FILE.md5 $BACKUP_DIR/$NAME.md5
}

And I call backup() thusly:
backup "private" "tank/private" 52428800 "my.backup.bucket"

Filed under: coding, technology 2 Comments