Skip to content

Instantly share code, notes, and snippets.

+-----------------------------+
| ^^^^ / ~|
| ^^^ --------- /|
| ^^ Simple / -------- |
| / ~ / ** |
| / / **** |
| ---- ~ / ****** |
| / ~~ ---- ****** |
| / / **** |
| / ~~ / ⌂⌂⌂⌂|
get '/' do
@stories = Dir.glob("#{stories_root}/*").map {|q| q.gsub!(/^.*\//,"") }
erb <<-HTML
<ul>
<% @stories.each do |story| %>
<li><a href="/<%= story %>"><%= story %></a></li>
<% end %>
</ul>
HTML
def endpoint(query)
tokens = [
"XXXXX",
"YYYYY"
]
URI.encode "https://graph.facebook.com/search?q=#{query}&type=user&access_token=#{tokens[rand(2)]}"
end
@ashaw
ashaw / tumblr-oauth.rb
Last active September 27, 2015 14:57
module TumblrOauth
class Client
def initialize(options = {})
@consumer_key = options[:consumer_key]
@consumer_secret = options[:consumer_secret]
@token = options[:token]
@secret = options[:secret]
@proxy = options[:proxy]
end
$ curl "https://api.twitter.com/1/urls/resolve.json?urls\[\]=http://t.co/CZuUXUK6" -H "X-Phx:true"
require 'rubygems'
require 'rest-client'
g = "http://go"
o = "o"
loop do
url = g + o + "gle.com"
p "trying " + url
p RestClient.get(url).headers
# the ruby way
def slot_tag(name, &blk)
slot_article = Slot.find_by_name(name).article
blk.call slot_article
end
# the yehuda katz way
def slot_tag(name, &blk)
slot_article = Slot.find_by_name(name).article
capture slot_article, &blk
def ap_less_than_10(number)
lookup = {
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
var hasPermission = function(uid, cb) {
// are we allowed to publish to the user's wall?
var perm = "publish_stream";
var query = FB.Data.query('select ' + perm + ' from permissions where uid={0}', uid);
query.wait(function(rows) { cb(rows[0][perm]); }); // returns 1 or 0
}
$ curl -I http://t.co/a87DAaC
HTTP/1.1 301 Moved Permanently
Date: Sat, 20 Aug 2011 22:53:39 GMT
Server: hi
Location: http://nyti.ms/p8ZGNT
Cache-Control: private,max-age=300
Expires: Sat, 20 Aug 2011 22:58:39 GMT
Connection: close
Content-Type: text/html; charset=UTF-8