Skip to content

Instantly share code, notes, and snippets.

@mdeiters
mdeiters / response.json
Created July 23, 2011 01:40
response from the coderwall api
http://coderwall.com/mdeiters.json
http://coderwall.com/mdeiters.json&callback=someMethod
@mdeiters
mdeiters / gist:975231
Created May 16, 2011 20:04 — forked from mislav/gist:938183
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
#!/usr/bin/ruby
# This was a quick hack to download Facebook URLs from
# http://www.facebook.com/directory
#
# @author Ron Bowes
# @date 2010-07-11
require 'net/http'
require 'uri'
raise 'Rails 2.3.2 to_json method fails if you attempt to load JSON gem before active support is loaded' if defined?(JSON)
require 'json/add/rails'
require 'json/add/core'
require 'hpricot'
require 'open-uri'
railscasts_path = File.join(Rails.root, 'tmp', 'railscasts')
FileUtils.mkdir_p(railscasts_path)
feed = Hpricot(open("http://feeds.feedburner.com/railscasts"))
feed.search('enclosure') do |enclosure|
puts "Downloading: #{enclosure[:url]}"
`cd #{railscasts_path} && wget #{enclosure[:url]}`
end
require 'rubygems'
require 'json'
require 'rest_client'
def create_person(name)
JSON.parse RestClient.post( "http://localhost:8988/neo4jr-social/nodes", :name => name )
end
def make_mutual_friends(node1, node2)
RestClient.post "http://localhost:8988/neo4jr-social/nodes/#{node1['node_id']}/relationships", :to => node2['node_id'], :type => 'friends'
#added this method to Game model
#To see more about reading and writing csv files, see http://fastercsv.rubyforge.org/
def self.convert_games_to_csv(games)
require 'fastercsv' #<= This require statement really belongs at the top of the config/environment.rb file
csv = ['home team', 'away team', 'home scroe', 'away score'].to_csv
games.each do |game|
csv << [game.home_team.name, game.away_team.name, game.home_score, game.away_score].to_csv
end
csv
def index
@games = Game.all
respond_to do |format|
format.html #so we can still respond to requests from browsers
format.xml do
render :xml => @games.to_xml
end
end
end
# 1. Register for an account at clickatell (), you should get 10 free sms messages
# 2. Install the clickatell gem by typinging: gem install clickatell
# Documentation: http://github.com/lukeredpath/clickatell
api_id = ENV['CLICKATELL_ID']
username = ENV['CLICKATELL_USERNAME']
password = ENV['CLICKATELL_PASSWORD']
require 'rubygems'
require 'clickatell'
<%= javascript_include_tag :defaults %>