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
(function(x) { | |
return x.split("\n").sort().join("\n"); | |
}) |
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
(defn wrap-token | |
[handler & [{:as options}]] | |
(fn [request] | |
(let [token (:token (:params request))] | |
(if (= token "MAGIC-KEY") | |
(handler request) | |
{ :status 403 :body "Forbidden" })))) |
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
File.readlines(ARGV[0]).each do |l| | |
l.chomp! | |
xs = l.split("\t") | |
"@ MX ALT1.ASPMX.L.GOOGLE.COM. 20 1800" | |
if xs.count == 5 | |
owner, rtype, tdata, pref, ttl = xs | |
pref = nil if pref.strip == "0" | |
next if rtype.strip == 'URL' | |
puts [owner, ttl, "IN", rtype, pref, tdata].compact.join("\t") | |
# example.com. IN MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com |
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
# ruby grab_venues.rb will print a csv of all the foursquare venue types | |
# flattens the nested hash of venues | |
url = "https://api.foursquare.com/v2/venues/categories?oauth_token=your_token&v=20120828" | |
require 'json' | |
# hashes are nested, containing arrays of hashes of category information | |
def print_hash(hash) | |
# We've found a category |
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
token = SecureRandom.urlsafe_base64 | |
# Naive, but with ~64^16 possibilities conflicts aren't a worry yet | |
# > 5,000,000.times {x << SecureRandom.urlsafe_base64}; puts x.uniq.count | |
# 5000000 | |
while Checkin.where(:token => token).any? | |
token = SecureRandom.urlsafe_base64 | |
end |
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
def create_reply(message) | |
reply_url = "https://api.foursquare.com/v2/checkins/#{checkin_id}/reply" | |
url = URI.parse(reply_url) | |
req = Net::HTTP::Post.new(url.path) | |
# token is a one time use secure random string | |
params = { :url => "http://www.hashtagmom.com/notify_mom/#{token}/", | |
:text => message, | |
:oauth_token => user.foursquare_access_token, | |
:v => "20120827" } | |
req.set_form_data(params) |
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
def create_post | |
url = URI.parse("https://api.foursquare.com/v2/checkins/#{checkin_id}/addpost") | |
req = Net::HTTP::Post.new(url.path) | |
params = { :url => "http://www.hashtagmom.com", | |
:text => message, | |
:oauth_token => user.foursquare_access_token, | |
:v => "20120827" } | |
req.set_form_data(params) | |
http = Net::HTTP.new(url.host, url.port) | |
http.use_ssl = true |
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
require 'rubygems' | |
require 'right_aws' | |
aws_access_key_id = '' | |
aws_secret_access_key = '' | |
target_bucket = 'bucket_with_data_to_copy' | |
destination_bucket = 'to_copy_into' | |
s3 = RightAws::S3Interface.new(aws_access_key_id, aws_secret_access_key) |
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
require 'rubygems' | |
require 'right_aws' | |
require 'yaml' | |
filename = ENV['FILE'].to_s | |
source = ENV['FROM'].to_s | |
destination = ENV['TO'].to_s | |
dry_run = true | |
puts "Please provide filename of s3 configuration" and exit(1) if filename == "" |
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
require 'rubygems' | |
require 'right_aws' | |
require 'yaml' | |
filename = ENV['FILE'].to_s | |
source = ENV['FROM'].to_s | |
destination = ENV['TO'].to_s | |
dry_run = true | |
puts "Please provide filename of s3 configuration" and exit(1) if filename == "" |