Wednesday, August 19, 2009

Balsamiq is the New Visio

Balsamiq Mockups rocks!
After a brainstorming meeting, instead of taking the "traditional" cellphone snapshot of the whiteboard, I simply went back to my room and made a mockup of the new screen for the meeting summary email. It took literally under five minutes.

I think I will include mockups in all specification documents from now on. It's just so easy and fun to do!

P.S.: PS3 slim edition is out...

Wednesday, August 12, 2009

Adobe AIR on Gentoo

Balsamiq Mockups for the desktop (www.balsamiq.com) is a nice tool for generating nice looking mockups real fast (much faster than visio, for example).
I've been using the web based trial version until today, when I got my license.

Running Balsamiq locally requires installing Adobe AIR on my machine, something I haven't got to doing until now. Installing the linux version of the AIR on gentoo didn't work at all (the installer binary just exits without any message).

Trying to resolve this, one of the first google search results was a nice guide for gentoo. And it worked flawlessly - basically you need to unpack the AIR SDK instead of using the installer.

I've also written a slightly more sophisticated shell script for running AIR apps, which allows specifying the app on the command line as well as symlinking.

/usr/local/bin/air:

#!/bin/sh

SDK_DIR="/usr/local/air_1.5_sdk"
APPS_DIR="/usr/local/air_apps"

BASE="$(basename $0)"


if [ -n "$1" ]
then
APP_NAME="$1"
if [ ! -d "$APPS_DIR/$APP_NAME" ]
then
echo "App $APP_NAME not found in $APPS_DIR" > /dev/stderr
exit 1
fi

else
APP_NAME="$BASE"
if [ ! -d "$APPS_DIR/$APP_NAME" ]
then echo "App $APP_NAME not found in $APPS_DIR" > /dev/stderr
echo "Usage: $(basename $0) " > /dev/stderr
exit 1
fi
fi

exec "$SDK_DIR/bin/adl" -nodebug "$APPS_DIR/$APP_NAME/META-INF/AIR/application.xml" "$APPS_DIR/$APP_NAME"


Now simply unpack balsamiq in /usr/local/air_apps/balsamiq, symlink and you're ready to go:
$ mkdir /usr/local/air_apps/balsamiq && unzip MockupsForDesktop.air -d /usr/local/air_apps/balsamiq
$ ln -s air /usr/local/bin/balsamiq
$ balsamiq &


Update: Support passing command line arguments to the air application (note that for balsamiq to open a file given on the command line, a full absolute path needs to be given)

#!/bin/sh

SDK_DIR="/usr/local/air_1.5_sdk"
APPS_DIR="/usr/local/air_apps"

BASE="$(basename $0)"

if [ "$BASE" = air -a -n "$1" ]
then
APP_NAME="$1"
if [ ! -d "$APPS_DIR/$APP_NAME" ]
then
echo "App $APP_NAME not found in $APPS_DIR" > /dev/stderr
exit 1
fi

shift

else
APP_NAME="$BASE"
if [ ! -d "$APPS_DIR/$APP_NAME" ]
then
echo "App $APP_NAME not found in $APPS_DIR" > /dev/stderr
echo "Usage: $(basename $0) " > /dev/stderr
exit 1
fi
fi

exec "$SDK_DIR/bin/adl" -nodebug "$APPS_DIR/$APP_NAME/META-INF/AIR/application.xml" "$APPS_DIR/$APP_NAME" -- "$@"

Sunday, August 9, 2009

Doing More For Gentoo

Last week I needed to dump a remote svn repository without local access. After searching for the best way to do it I finally chose rsvndump (because it allows dumping a subdirectory of the repository).

As usual, I created an ebuild in order to install it, and posted it in a bug. As some of my bugs are pretty much ignored for a long period, I took the advice to post it to the sunrise overlay.

A week later, after multiple reviews and touch ups (those guys are strict!) the ebuild is now available in the sunrise overlay.

This took a little more effort than just posting the bug, but the ebuild is now of much higher quality (and I learned quite a bit more about ebuilds). It should be easier for the devs to include it in portage this way.

Thursday, August 6, 2009

Revised highlighting script to use sed = full regex support

I had a TODO in the header of my bash highlighting script (hl) for a long time to add support for case insensitive highlighting and regex support, for a very long time.

Today I finally fixed it by changing the script to use sed.

Example usage:

$ glxinfo | hl GL_ARB_multitexture\|GL_EXT_framebuffer_object
\|GL_ARB_shader_objects\|GL_ARB_shading_language_100
\|GL_ARB_fragment_shader


The script:
#!/bin/sh
# Highlight specified pattern

RED=`echo -en '\e[31m'`
GREEN=`echo -en '\e[32m'`
YELLOW=`echo -en '\e[93m'`
NORMAL=`echo -en '\e[00m'`

usage () {
echo "Usage: `basename $0` [red | green | yellow] str"
exit 1
}


[ "$1" ] || usage

if [ -n "$2" ]
then
case $1 in
red) COLOR="$RED";;
green) COLOR="$GREEN";;
yellow) COLOR="$YELLOW";;
*) usage;;
esac

shift
else
COLOR="$RED"
fi

STR="$1"

sed -E "s/($STR)/$COLOR\1$NORMAL/g"

Sunday, August 2, 2009

Faking an email sender address

It's been a while since I last blogged, been busy...

It is a pretty well known fact that the SMTP protocol is very insecure, and it is easy to spoof and fake email messages. I've encountered a legitimate use case today.

Imagine you've had an email account where you keep all your stuff for archiving purposes (what? you don't keep your inbox at 0 messages?!) and let's say one day you accidentally remove all your messages. Alternatively, your SP may have gone belly up.

Fortunately, you made a backup so you have all your emails sitting safely on your local HD. But now your email is fragmented. All email you received until today is stored on your HD and anything new will be received at you actual email account. That could suck when you'd want to run a global search to find an email you can't quite remember when you received it.

So you could resend all those emails from the backup to your mail account, but then they would all seem to originate from the same source - you!

That's a lot of information lost. In this case it would be better to keep the original sender. Here's an example on how to achieve this with ssmtp (a lightweight MTA).

Make sure you've configured it to look for from addresses in the actual message text. In /etc/ssmtp/ssmtp.conf you should have:
FromLineOverride=YES

You also need to configure a mailhub for ssmtp to work, obviously:
mailhub=mailserver.corp.foo.bar

Now execute ssmtp (you'd probably want to create a script for this for mass mailing your backup):
# sendmail me@mail.corp.foo.bar
From: someone@somewhere.com
To: me@mail.corp.foo.bar
Subject: Fake from field
I've sent this with a fake from field using ssmtp.
[EOF]

Note that the from address (someone@somewhere.com) is completely bogus for the current session (so the email will appear to originate from the original sender). Pay attention that ssmtp seems to be looking for exactly 'From:' (case sensitive).

I haven't tried it, but the same principle should also work to preserve the original date of the email.