Created
July 29, 2009 01:40
-
-
Save mml/157806 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# See http://github.com/mml/needy for a new project based on this script. | |
# Script to let me know which projects are getting a bit stale. | |
# | |
# Sample output: | |
# flickr: 379.8 hours | |
# ol: 219.6 hours | |
# lj: 65.4 hours | |
# twitter: 20.0 hours | |
# ep: 1.5 hours | |
# m0x65: 1.1 hours | |
# | |
# Sometimes it slowly creeps up on you that you haven't done anything with X in | |
# a few weeks... or even months, and next thing you know getting started again | |
# seems somewhat hard. I am pretty prone to this kind of problem; I guess that | |
# part of my brain doesn't work very well. So this is a simple attempt to | |
# factor that part of my brain out in to some code. | |
# | |
# See notes at the bottom | |
imap_time() { | |
ruby -rnet/imap -rtime -e " | |
query = ARGV.map{|whom| %Q{TO #{whom}}}.reduce {|memo,q| %Q{OR #{q} #{memo}}} | |
imap = Net::IMAP.new 'imap.gmail.com', 993, true | |
imap.login '[email protected]', 'PASSWORD' | |
imap.select '[Gmail]/Sent Mail' | |
last_id = imap.search(query).max | |
last = Time.parse(imap.fetch(last_id, 'envelope')[0].attr['ENVELOPE'].date).to_i | |
puts %Q{$1: #{last}} | |
" "$@" & | |
} | |
feed_time() { | |
echo "$1": $( | |
curl -s "$2" \ | |
| ruby -rtime -ne ' | |
if $_ =~ /<(?:updated|pubDate)>(.*)<\/(?:updated|pubDate)>/ | |
puts Time.parse($1).to_i | |
exit | |
end' | |
) & | |
} | |
( | |
imap_time MY_FRIEND HIS_OTHER_EMAIL | |
imap_time MY_CLIENT | |
imap_time MY_BUSINESS_PARTNER | |
imap_time MY_MOM | |
( | |
export GIT_DIR=$HOME/s/ep/.git | |
git svn fetch | |
echo ep: $(git log remotes/git-svn --author=mattl --pretty=%ct -n1) | |
) & | |
( | |
export GIT_DIR=$HOME/s/ol/.git | |
git fetch | |
echo ol: $(git log origin/master --pretty=%ct -n1) | |
) & | |
( | |
export GIT_DIR=$HOME/s/m0x65/.git | |
echo m0x65: $(git log prod/master --pretty=%ct -n1) | |
) & | |
feed_time lj http://inpetto.livejournal.com/data/atom | |
feed_time twitter http://twitter.com/statuses/user_timeline/820244.rss | |
feed_time flickr 'http://api.flickr.com/services/feeds/photos_public.gne?id=44124458037@N01&lang=en-us&format=atom' | |
feed_time tumblr http://tumble.mml.name/rss | |
wait | |
)\ | |
| sort -nk2 \ | |
| ruby -pe ' | |
$_.gsub!(/\d+$/){sprintf "%.1f hours", (Time.now - Time.at($&.to_i))/60/60} | |
' | |
# The things checked in this example are: people I should email, an SVN repo | |
# (that I attach to with git), 2 git repos (one where I first check the remote, | |
# and one where I don't bother), my LiveJournal, flickr, Twitter, and my | |
# tumblelog. In principle, this could be modified to check things like | |
# - manually entered data (last time you read $BOOK) | |
# - age of messages in a folder (like TO_REPLY, or even just your inbox) | |
# - last time you IM'd with $PERSON | |
# | |
# And the algorithms could be played with in many ways, including | |
# - mean age of last N commits/entries | |
# - mean product size*(K - age) of last N commits/entries | |
# - a bit-second? | |
# - exponentially-weighted moving averages instead of flat averages | |
# - derivatives of any of these | |
# | |
# And at some point, better data visualization might be worthwhile. E.g., | |
# something like gauges on a dashboard. | |
# | |
# Yes, this is a shell script of things you could probably do inside Ruby, | |
# Python, or Perl. No, it is not a web app. Yes, it uses shell functions. | |
# Yes, I am hopelessly in love with pipes and linewise data. Want to make | |
# something of it? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment