This file contains 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
class TweetsController < ApplicationController | |
before_action :create_client | |
def index | |
batch_size = 10 | |
@twitter_handle = "dhh" | |
@tweets = @client.user_timeline(@twitter_handle).take(batch_size) | |
@friends = @client.friends(@twitter_handle).take(batch_size) |
This file contains 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
" Vim color file | |
" Converted from Textmate theme Monokai Refined using Coloration v0.3.2 (http://github.com/sickill/coloration) | |
set background=dark | |
" highlight clear | |
highlight Normal guibg=black guifg=white | |
if exists("syntax_on") | |
syntax reset | |
endif |
This file contains 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 'asin' | |
require 'awesome_print' | |
ASIN::Configuration.configure do |config| | |
config.associate_tag = 'carlscorn-20' | |
config.key = 'AKIAJHAI7AL2VNXA4JWA' | |
config.secret = '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' | |
end |
This file contains 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
# Gem that wraps around the Gist API | |
# https://github.com/sinisterchipmunk/active-gist | |
require 'activegist' | |
# GitHub Gist API documentation: | |
# - http://developer.github.com/v3/gists/ | |
# Set up credentials. | |
ActiveGist::API.username = "Your GitHub username" | |
ActiveGist::API.password = "Your GitHub password" |
This file contains 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://nokogiri.org/Nokogiri/XML/Node.html#method-i-css | |
require 'mechanize' | |
require 'csv' | |
puts "Product Scraper!!!" | |
puts ' ' | |
urls = [ | |
"http://www.zappos.com/seavees-teva-universal-sandal-concrete", |
This file contains 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://www.ruby-doc.org/stdlib-2.0/libdoc/benchmark/rdoc/Benchmark.html | |
require 'benchmark' | |
# http://www.ruby-doc.org/stdlib-2.0.0/libdoc/bigdecimal/rdoc/BigMath.html | |
require 'bigdecimal/math' | |
# Set the number of iterations to run. The underscore here is used as a substitute for normal comma so Ruby interprets the number correctly. | |
iterations = 10 | |
puts "\nCalculating pi #{iterations} times.\n\n" |
This file contains 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 'bundler/capistrano' | |
# Include this if you want to be able to set up different deployment stages (i.e. beta, stage, etc.) | |
# require 'capistrano/ext/multistage' | |
set :application, "example.com" | |
set :user, "linuxusername" | |
default_run_options[:pty] = true | |
set :use_sudo, true |
This file contains 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://ruby-doc.org/stdlib-2.0.0/libdoc/open-uri/rdoc/OpenURI.html | |
require 'open-uri' | |
# Go fetch the contents of a URL & store them as a String | |
response = open('http://www.example.com').read | |
# "Pretty prints" the result to look like a web page instead of one long string of HTML | |
URI.parse(response).class | |
# Print the contents of the website to the console |
This file contains 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
# MySQL. Versions 4.1 and 5.0 are recommended. | |
# | |
# Install the MySQL driver: | |
# gem install mysql2 | |
# | |
# And be sure to use new-style password hashing: | |
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
development: | |
adapter: mysql2 | |
encoding: utf8 |
This file contains 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 'mechanize' | |
require 'csv' | |
# Load up the trending Ruby repos on GitHub from the last month. | |
url_to_scrape = "https://github.com/trending?l=ruby&since=monthly" | |
# Snag the website with Mechanize & parse it into an XML document we can query. | |
page = Mechanize.new.get(url_to_scrape) | |
# Set the name of the CSV we'll create & load from. | |
file = "repo_data.csv" |
OlderNewer