Instantly share code, notes, and snippets.

View bluemix.rb
require 'asin'
require 'awesome_print'
ASIN::Configuration.configure do |config|
config.associate_tag = 'carlscorn-20'
config.key = 'AKIAJHAI7AL2VNXA4JWA'
config.secret = 'Qj1fACFPNfyHah67b/OySg4ZpSxt1O6jKDc4gXZK'
View database.yml.example mysql2
# 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:
adapter: mysql2
encoding: utf8
View deploy.rb
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, ""
set :user, "linuxusername"
default_run_options[:pty] = true
set :use_sudo, true
View VimMonokai.vim
" Vim color file
" Converted from Textmate theme Monokai Refined using Coloration v0.3.2 (
set background=dark
" highlight clear
highlight Normal guibg=black guifg=white
if exists("syntax_on")
syntax reset
View ruby_benchmark_examples.rb
require 'benchmark'
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"
View ruby_github_gist_api.rb
# Gem that wraps around the Gist API
require 'activegist'
# GitHub Gist API documentation:
# -
# Set up credentials.
ActiveGist::API.username = "Your GitHub username"
ActiveGist::API.password = "Your GitHub password"
View json_response_handling_ruby.rb
require 'open-uri'
require 'json'
require 'pp'
# Construct the URL we'll be calling
request_uri = 'http://localhost:3000/users.json'
request_query = ''
View ruby_web_scraping.rb
require 'mechanize'
require 'csv'
# Load up the trending Ruby repos on GitHub from the last month.
url_to_scrape = ""
# Snag the website with Mechanize & parse it into an XML document we can query.
page =
# Set the name of the CSV we'll create & load from.
file = "repo_data.csv"
View ruby-open-uri-request.rb
require 'open-uri'
# Go fetch the contents of a URL & store them as a String
response = open('').read
# "Pretty prints" the result to look like a web page instead of one long string of HTML
# Print the contents of the website to the console