/dev/nikc/blog

Kuolleiden purjehduskenkien seura

Shorts

Sep 14th 2010

Dummy sendmail for development environments

21:21

Most developers working with the web will sooner or later need to deal with sending e-mail. Usually it’s a contact or feedback form that needs to be delivered to an inbox in a nearby universe.

What has been bugging me about this is that whenever I need to send e-mail, I actually need to use e-mail, which slows things down and is cumbersome in so many ways, since your sysadmin didn’t configure the mailer on the development server – and more often than not, that development environment is your own laptop and I certainly don’t want to setup a working mailer on mine. Besides, I might not even be connected to a network. And don’t even get me started on when you need to dry run bulk mailing.

Luckily, at least if you’re running *nix, there’s a very simple solution; replace your sendmail binary with the following shell script1:

<code>#!/bin/bash

LOGDIR="/tmp/sendmail-sim"
NOW=$(date +%Y-%m-%dT%H.%M.%S)
CNT=1
PRIVATELOG="$LOGDIR/$NOW.$CNT.log"
COMBINEDLOG="$LOGDIR/combined.log"

# If privatelogs are being used...
if [ ! -z "$PRIVATELOG" ]; then
    # ...make sure the filename is unique and create the file
    while [ -f $PRIVATELOG ]; do
        CNT=$(($CNT + 1))
        PRIVATELOG="$LOGDIR/$NOW.$CNT.log"
    done

    echo "$0 $*" > $PRIVATELOG
else
    # ...otherwise swap filenames
    PRIVATELOG=$COMBINEDLOG
    COMBINEDLOG=''
fi

echo "[$NOW]" >> $PRIVATELOG
while read BUF
do
    echo $BUF >> $PRIVATELOG
done

# Append privatelog to combinedlog when both logs are used
if [ ! -z "$COMBINEDLOG" ]; then
    echo "[$NOW]" >> $COMBINEDLOG
    cat $PRIVATELOG >> $COMBINEDLOG
fi

exit 0</code>

This will result in all input that is sent to sendmail being written to a separate2 log file in the /tmp/sendmail-sim directory, as well as a combined.log for convenient tailing.

Shorts

Aug 26th 2010

Androids’ march against pirates

17:18

Tim Bray also says that “the best attack on pirates is to make their work more difficult and expensive, while simultaneously making the legal path to products straightforward, easy, and fast.”

Right on Tim, but…

Google’s Android Market lets you install paid applications only if you are in one of the 13 supported countries. The “legal path” is neither “straightforward, easy, or fast” if you don’t live in one of the 13 countries that are supported. Maybe instead of focusing on developing anti-piracy services, Google should add more locations to the paid Android Market.

Android Market and Piracy

Shorts

  • bq.. There are only two hard things in Computer Science: cache invalidation, naming things, off by one errors.

    Phil Karlton

    (0) #

  • “The camera described in this report represents a first attempt demonstrating a photographic system which may, with improvements in technology, substantially impact the way pictures will be taken in the future.”

    But in reality, we had no idea…

    (0) #

  • Frustrated by the Web

    (0) #

Feb 28th 2010

So long, and thanks for all the fish!

10:40

By the looks of it, this blog seems to have failed the test of time. I’ve had fuck all to say for over 2 months now. Not even a single link worth posting. Not a single photo worth showing.

So, until I find a new boost of inspiration somewhere, the status of /dev/nikc/blog is discontinued.

Shorts

Oct 23rd 2009

Magic in Google Reader

09:56

Being a subscriber to a plethora of photo blogs, I was very pleased when I recently learned that Google Reader was equipped with a feature to give a lesser preference to “spamming” (i.e. frequently updating) streams by choosing the Sort by Auto, thus diminishing the urge to use the “Mark all as read” button when the reading list grows to numbers uncomprehensible to all but the most brilliant mathematicians in world history.

It was almost like magic, and it seems Google now thinks so too.

Shorts

Oct 14th 2009

French Connection

09:06

French Gold

Meta

Pages

Search blog

Latest comments