Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created March 7, 2009 19:32
Show Gist options
  • Select an option

  • Save wfarr/75414 to your computer and use it in GitHub Desktop.

Select an option

Save wfarr/75414 to your computer and use it in GitHub Desktop.
(defun yql-fetch-latest-tweet (user)
(interactive "sWhich user?: ")
(let* ((result
(yql-filter
'item
(yql-select
"title,pubDate" "rss"
(format "url='http://twitter.com/statuses/user_timeline/%s.rss' LIMIT 1" user))))
(tweet-time
(eval
(cons 'encode-time
(parse-time-string (yql-filter 'pubDate result)))))
(tweet-text
(replace-regexp-in-string
(format "^%s: " user) ""
(yql-filter 'title result)))
(tweet (concat "("
(cond ((string= (format-time-string "%D")
(format-time-string "%D" tweet-time))
(format-time-string "%I:%M %p, Today" tweet-time))
((eq (cadddr (decode-time tweet-time))
(- (cadddr (decode-time (current-time))) 1))
(format-time-string "%I:%M %p, Yesterday" tweet-time))
(t
(format-time-string "%I:%M %p %D" tweet-time)))
") " tweet-text)))
tweet))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment