Skip to content

Instantly share code, notes, and snippets.

@pjf
Created April 14, 2013 00:01
Show Gist options
  • Save pjf/5380694 to your computer and use it in GitHub Desktop.
Save pjf/5380694 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie qw( :all );
use WebService::Beeminder;
use Config::Tiny;
# use Smart::Comments;
# Get our beeminder auth token.
my $config = Config::Tiny->read("$ENV{HOME}/.rtbmrc");
$config or die "Can't read ~/.rtbmrc config file";
my $token = $config->{Beeminder}{auth_token};
my $bee = WebService::Beeminder->new( token => $token );
my $goals = $bee->user(
skinny => 1, goals_filter => 'frontburner', diff_since=>1,
)->{goals};
my $now = time();
foreach my $goal (sort { $a->{losedate} <=> $b->{losedate} } @$goals) {
my $timeleft = timeleft($goal->{losedate} - $now);
say "[$timeleft] $goal->{slug}";
}
sub timeleft {
my ($sec) = @_;
my $days = int($sec / 86400);
my $hrs = int( ($sec - ($days * 86400))/3600);
return "${days}d ${hrs}hrs";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment