Skip to content

Instantly share code, notes, and snippets.

@semikolon
Forked from Yuffster/brew.pl
Created January 14, 2009 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save semikolon/46976 to your computer and use it in GitHub Desktop.
Save semikolon/46976 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
#
# Copyright (c) 2009 Michelle Steigerwalt <msteigerwalt.com>
# All rights reserved.
#
# Handy-dandy tea brewing timer. Uses Growl for messaging.
#
# Normal Mode:
# > brew oolong
# Steeping for five minutes.
#
# Help Mode:
# > brew -h oolong
# 2 tsp of oolong will yield 8 oz. of tea. Steep time 5 minutes.
#
# Optional -m tag for multiple infusions will add a minute to the
# steeping time to account for used leaves.
#
use Getopt::Long;
use Mac::Growl;
$Types = ["Steeping Complete", "Message notification"];
Mac::Growl::RegisterNotifications('teatimer', $Types, $Types);
GetOptions("h"=>\$helpmode, "m"=>\$multiple);
$teas = {};
$teas{'white'} = [3, 5];
$teas{'green'} = [2, 3];
$teas{'pearl'} = [1, 5];
$teas{'oolong'} = [2, 5];
$teas{'black'} = [2, 5];
$teas{'yerba'} = [3, 5];
$teas{'chamo'} = [3, 7];
$teas{'catnip'} = [1, 5];
$type = $ARGV[0];
if (!defined $teas{$type}) {
print "I'm not familiar with $type tea, is it delicious?\n";
print "Treating this tea as a black tea.\n";
$type = 'black';
}
$steepfor = $teas{$type}[1];
#Brew an extra minute if this is a second infusion.
if ($multiple) {
print "Adding a minute to steep time, as this is a secondary infusion.\n";
$steepfor++;
}
if (defined $helpmode) {
$ounces = $ARGV[1];
if (!$ounces) { $ounces = 8; }
$peroz = $teas{$type}[0];
$tspns = $ounces * ($peroz/8);
print "$tspns tsp of $type will yield $ounces oz. of tea. Steep time $steepfor minutes.\n";
exit;
}
print "Steeping for $steepfor minutes.\n";
sleep $steepfor*60;
Mac::Growl::PostNotification('teatimer', "Steeping Complete", "Mmm, $type!", "Your tea has finished steeping. Please remove the infuser immediately.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment