Skip to content

Instantly share code, notes, and snippets.

View wfarr's full-sized avatar
:shipit:
shipping

Will Farrington wfarr

:shipit:
shipping
View GitHub Profile
(defmacro test (query &rest args)
`(let ((query-args
(mapcar
(lambda (x)
(coerce (symbol-name x) 'string))
(quote ,args))))
query-args))
(test 'select item.condition.temp weather.forecast location=30332)
Debugger entered--Lisp error: (wrong-type-argument sequencep item\.condition\.temp)
coerce(item\.condition\.temp string)
(lambda (x) (coerce x (quote string)))(item\.condition\.temp)
mapcar((lambda (x) (coerce x (quote string))) (item\.condition\.temp weather\.forecast location=30332))
(let ((query-args ...)) query-args)
(test (quote select) item\.condition\.temp weather\.forecast location=30332)
eval((test (quote select) item\.condition\.temp weather\.forecast location=30332))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
(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
(let ((results (yql 'filter
'item
(yql 'select
"title,pubDate" "rss"
"url='http://twitter.com/statuses/user_timeline/wfarr.rss' LIMIT 1"))))
(print (yql 'filter 'title results))
(print (yql 'filter 'pubDate results)))
;; Prints:
;; "wfarr: @20seven @joshjgt and I are working on our Yahoo Hack Week project, by creating an elisp library for it! http://tinyurl.com/c2eddc"
(defun yql-yahoo-search (query)
(let ((result (yql-filter 'result
(yql-select "title,abstract,url" "search.web"
(concat (format "query=\"%s\"" query)
"LIMIT 5")))))
(save-excursion
(set-buffer (get-buffer-create "*Search Results*"))
(dolist (item result)
(let ((title (yql-filter 'title item))
;; Ran: (yql-make-request "select content from flickr.places where query=\"north beach\" limit 1")
((query
(results
(place . "North Beach, San Francisco, CA, United States"))
(diagnostics
(build-version . "911")
(service-time . "125")
(user-time . "128")
(url ... ...)
;; Ran: (yql-make-request "select place_url from flickr.places where query=\"north beach\" limit 1")
((query
(results
(place
(place_url . "/United+States/California/San+Francisco/North+Beach")))
(diagnostics (build-version . "911")
(service-time . "152")
(user-time . "158")
(url
;; Ran: (yql-make-request "select * from flickr.places where query=\"north beach\" limit 1")
((query
(results
(place
(content . "North Beach, San Francisco, CA, United States")
(woeid . "2460640")
(timezone . "America/Los_Angeles")
(place_url . "/United+States/California/San+Francisco/North+Beach")
(place_type_id . "22")
((query (results (table . ["atom" "csv" "feed" "flickr.photos.exif" "flickr.photos.info" "flickr.photos.interestingness" "flickr.photos.recent" "flickr.photos.search" "flickr.photos.sizes" "flickr.places" "flickr.places.info" "geo.places" "geo.places.ancestors" "geo.places.belongtos" "geo.places.children" "geo.places.neighbors" "geo.places.parent" "geo.places.siblings" "geo.placetypes" "gnip.activity" "html" "json" "local.search" "microformats" "mybloglog.community.find" "mybloglog.member" "mybloglog.member.contacts" "mybloglog.member.newwithcontacts" "mybloglog.member.newwithme" "mybloglog.members.find" "rss" "search.images" "search.news" "search.web" "upcoming.category" "upcoming.country" "upcoming.events" "upcoming.events.bestinplace" "upcoming.groups" "upcoming.metro" "upcoming.state" "upcoming.user" "upcoming.venue" "weather.forecast" "xml" "yap.setsmallview"])) (diagnostics (build-version . "911") (service-time . "0") (user-time . "1") (publiclyCallable . "true")) (uri . "http://query.yahooapis.com/v1/y
#!/usr/bin/env ruby
require 'mathn'
def sign(x)
return 1 if x > 0
return -1 if x < 0
return 0
end