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
http://coderwall.com/mdeiters.json | |
http://coderwall.com/mdeiters.json&callback=someMethod |
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
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' |
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
#!/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' |
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
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' |
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 '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 |
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 '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' |
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
#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 |
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 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 |
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
# 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' |
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
<%= javascript_include_tag :defaults %> |