Skip to content

Instantly share code, notes, and snippets.

@Yuffster
Created January 14, 2009 16:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Yuffster/46946 to your computer and use it in GitHub Desktop.
Save Yuffster/46946 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 for Maccies and Irssi.
#
# OSX Requirements:
#
# Uses Growl for messaging. Requires the Growl Perl modules. This could be
# made to work on Linux, but I don't know the best way to do the
# notification.
#
# Example Usage:
#
# Sets timer for the optimum steep time of oolong:
# > brew oolong
#
# Provides the optimal tea quantities for brewing 40 oz of oolong.
# > brew -h oolong 40
#
# Sets the timer for a two minute steep time.
#
# > brew -t 2 oolong
#
# 10 tsp of oolong will yield 40 oz. of tea. Steep time 5 minutes.
#
# Optional Flags:
# -h help mode:
# will inform the user of the proper quantities of tea relative to the
# amount of water (oz) used.
# -l light mode:
# will decrement brew time by one minute to allow for a lighter brew.
# -m multiple infusions:
# will add a minute to the steeping time to account for used leaves.
# -t time:
# manually provide a steeping time (in minutes).
#
use Getopt::Long;
use Mac::Growl;
$Types = ["Steeping Complete"];
Mac::Growl::RegisterNotifications('teatimer', $Types, $Types);
GetOptions("h"=>\$helpmode, "m"=>\$multiple, "l"=>\$light, "t:i"=>\$time);
# Initialize option variables.
$type = $ARGV[0];
$ounces = $ARGV[1];
# Default to black tea.
$type = $type ? $type : "black";
###############################################################################
# Yummy Tea Information. Format: [tsp per oz, steep time, information]
###############################################################################
$teas = {};
$teas{'white'} = [3, 5,
"White tea is the uncured and unoxidized tea leaf. Like green, oolong and black
tea, white tea comes from the Camellia sinensis plant. White tea is fast-dried,
while green tea is roasted in an oven or pan (while kept moving for even
curing). Oolong and black teas are oxidized before curing."];
$teas{'green'} = [2, 2,
"Green tea is a type of tea made solely with the leaves of Camellia sinensis
which has undergone minimal oxidation during processing. It should be brewed at
slightly below boiling temperatures to maintain optimum flavor."];
$teas{'pearl'} = [1, 4,
"Pearl tea is a form of green Chinese tea produced in Zhejiang Province of China
in which each leaf has been rolled into a small round pellet."];
$teas{'oolong'} = [2, 4,
"Oolong has a taste more akin to green tea than to black tea: it lacks the rosy,
sweet aroma of black tea but it likewise does not have the stridently grassy
vegetal notes that typify green tea. It is commonly brewed to be strong, with
the bitterness leaving a sweet aftertaste."];
$teas{'black'} = [2, 4,
"Black tea is a variety of tea that is more oxidized than the oolong, green, and
white varieties. Black tea is generally stronger in flavor and contains more
caffeine than the less oxidized teas. Unlike green teas, which turn bitter when
brewed at higher temperatures, black tea should be steeped in freshly boiled
water."];
$teas{'yerba'} = [3, 5,
"The flavor of brewed yerba mate is strongly vegetal, herbal, and grassy,
reminiscent of some varieties of green tea. Unlike most teas, it does not become
bitter and astringent when steeped for extended periods. Mate should be steeped
in hot (as opposed to boiling) water."];
$teas{'chamo'} = [3, 7,
"Chamomile is an herbal tea used to soothe stomaches and as a gentle sleep aid."];
$teas{'catnip'} = [1, 7, "Meow."];
$teas{'rooibos'} = [4, 8,
"Rooibos tea is often described as being sweet and slightly nutty. Unlike black
tea, rooibos does not become bitter when steeped for a long time; some
households leave the tea to steep for days at a time. Rooibos tea is a reddish
brown colour, explaining why rooibos is sometimes referred to as \"red tea\"."];
$teas{'red'} = $teas{'rooibos'};
###############################################################################
# Let the user know if they're trying to get info for an unknown type of tea.
###############################################################################
if (!defined $teas{$type}) {
# Handle unknown type.
if (defined $type) {
print "I'm not familiar with $type tea, is it delicious?\n";
print "Treating this tea as a black tea.\n";
} $type = 'black';
}
# Get our tea information ready for use.
$peroz = $teas{$type}[0];
$steepfor = $teas{$type}[1];
$info = $teas{$type}[2];
###############################################################################
# Check for flags.
###############################################################################
if ($multiple) {
print "Adding a minute to steep time, as this is a secondary infusion.\n";
$steepfor++;
}
if ($light) {
print "Light tea desired; decreasing steep time by one minute.\n";
$steepfor--;
}
if ($strong) {
print "Strong tea desired; increasing steep time by one minute.\n";
$steepfor++;
}
if ($time) {
$steepfor = $time;
}
###############################################################################
# Help Mode
###############################################################################
if (defined $helpmode) {
# Default to one cup (eight ounces) of tea.
if (!$ounces) { $ounces = 8; }
$tspns = $ounces * ($peroz/8);
print "Infuse $tspns tsp of $type tea leaves with $ounces ounces of water.\n";
print "Steep time: $steepfor minutes.\n";
###############################################################################
# Real Mode
###############################################################################
} else {
print "Steeping for $steepfor minutes.\n";
sleep $steepfor*60;
#If the user didn't provide a type of tea, just call it 'tea' for growl purposes.
if (!defined $ARGV[0]) { $type = "tea"; }
$mess = "Your tea has finished steeping. Please remove the infuser immediately.";
Mac::Growl::PostNotification('teatimer', "Steeping Complete", "Mmm, $type!", $mess);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment