Skip to content

Instantly share code, notes, and snippets.

@daniel-fanjul-alcuten
Created October 9, 2012 17:22
Show Gist options
  • Save daniel-fanjul-alcuten/3860173 to your computer and use it in GitHub Desktop.
Save daniel-fanjul-alcuten/3860173 to your computer and use it in GitHub Desktop.
the giri of the day
#!/bin/bash
# installation procedure:
#
#$ aptitude install qdbm-util
#$ {
# crontab -l
# echo '1 0 * * 1-5 [email protected] ~/bin/tgotd.sh'
#} | crontab
file=${FILE:-~/etc/tgotd.dp}
email=${EMAIL:-dfanjul+giris@somewhere.com}
if ! [ -f "$file" ]; then
dpmgr create "$file"
fi
function ikey() {
if ! dpmgr get "$file" "$1" >/dev/null 2>&1; then
dpmgr put "$file" "$1" 0
fi
}
ikey fulanito
ikey menganito
giri=`dpmgr list "$file" | sort -k2 -n | head -1 | cut -f1`
subject="The giri of today is $giri [EOM]"
echo "$subject"
mail -s "$subject" "$email" < /dev/zero 2>/dev/null && \
dpmgr put "$file" "$giri" `date +%s`
@magmax
Copy link

magmax commented Oct 9, 2012

I really prefer python:

import os, random

users = ['fulanito', 'menganito']

giri = random.choose(users)
os.system('mail -s "The giri of today is {} [EOM] < /dev/zero 2>/dev/null'.format(giri))

It is soooooo beautiful....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment