Skip to content

Instantly share code, notes, and snippets.

@eigilhs
Created March 4, 2013 14:45
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 eigilhs/5082693 to your computer and use it in GitHub Desktop.
Save eigilhs/5082693 to your computer and use it in GitHub Desktop.
Script for å vise Dilbert-striper
#!/usr/bin/env python
import os, re, sys, urllib, random, datetime, time
root = "http://www.dilbert.com/"
address = root + "fast/" # today's strip
if len(sys.argv) == 2 and sys.argv[-1] != "-r": # specified strip
date = re.findall("\d\d\d\d\-\d\d\-\d\d", sys.argv[1].strip())
if date: address += date[0] + "/"
else: sys.exit("Illegal date: " + sys.argv[1] + "\nUse format YYYY-MM-DD.")
elif sys.argv[-1] == "-r": # random strip
current = time.time()
beginning = 608680800.0 # 1989-04-16
random_date = random.random() * (current - beginning)
address += str(datetime.date.fromtimestamp(beginning + random_date)) + "/"
for line in urllib.urlopen(address):
m = re.findall("dyn/str_strip/.*\.strip", line)
if m: break
image = root + m[0] + ".zoom.gif"
os.system("curl -s " + image + " | display &")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment