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/env ruby -ws | |
require 'open-uri' | |
require 'nokogiri' | |
require 'yaml' | |
require 'pathname' | |
require 'ostruct' | |
require 'pp' | |
require 'forwardable' | |
require 'minitest/unit' |
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
#!/bin/bash | |
# Provisioning script for an Ubuntu server to run a PostgreSQL server, NginX, | |
# and a Rack application behind a thin server, which can be deployed with | |
# Capistrano. | |
# | |
# This script needs to be run as root | |
# | |
# When it's run, you will still need to add your deploy users to the group, so | |
# that they can actually act on behalf of the named application user. And, | |
# obviously, they will need an account into which they can SSH, so you'll need |
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
# A very simple Rakefile for generating static sites. It's essentially Hobix, | |
# but probably simpler. Every page of the site is a YAML file. The YAML file | |
# gets compiled into a HTML file with the same basename. The content can be | |
# wrapped in a layout. | |
require 'rake/clean' | |
require 'open-uri' | |
require 'yaml' | |
require 'erb' | |
YML = FileList['**/*.yml'].exclude(/^[_.]/) |
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
# A dummy ActiveRecord application, useful for playing around with ActiveRecord, | |
# or for writing tests. Makes a Sqlite3 database in memory. | |
# | |
# Creates the following tables: | |
# | |
# - products | |
# - users | |
# - taggings | |
# - tags | |
# - categories |
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
cd ~/.pow | |
for f in ~/Projects/*; do [[ -e $f/config.ru ]] && ln -s $f `basename $f`; done |
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/env ruby | |
# encoding: utf-8 | |
# | |
# A silly script to demonstrate the Monty Hall Problem. | |
# http://en.wikipedia.org/wiki/Monty_Hall_problem | |
# | |
# Usage | |
# ruby [-v] monty.rb <n> | |
# where n is the number of times each of the 3 players plays the game. | |
# |
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/env ruby | |
require 'linode' | |
require 'open-uri' | |
$api_key = "MY LINODE API KEY" | |
$subdomain = "my.subdomain.example.com" | |
# Updates a Linode DNS record. Can be used to create a dynamic DNS within a | |
# domain of your own. Just set the subdomain to whatever. |
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/env ruby | |
$username = "08312345676" # Replace with your phone number | |
$password = "000000" # Replace with your webtext PIN | |
require 'mechanize' | |
# A simple three.ie webtext CLI. | |
# Requires Ruby 1.9 and Mechanize (gem install mechanize) | |
# Logs in, fills in the webtext form, submits it, and prints out the result. |
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
# Includes a file from a gem. Useful for reusing test helper files from the gems | |
# you're writing functionality for. | |
def gem_file(gem, file, *gem_requirements) | |
File.join(Gem::Dependency.new(gem, *gem_requirements).to_spec.gem_dir, file) | |
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 'active_record' | |
# A sample application, consisting of products, users, comments, categories, and whatnot. | |
module SampleApp | |
class Product < ActiveRecord::Base | |
belongs_to :user | |
has_many :comments, :as => :commentable | |
has_many :transactions | |
has_and_belongs_to_many :categories |