Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
COLOR_SOURCE_VALUES = 256 | |
COLOR_TARGET_VALUES = 5 | |
COLOR_DIVIDE = COLOR_SOURCE_VALUES / COLOR_TARGET_VALUES | |
TERM_COLOR_BASE = 16 | |
def rgb_to_xterm(r, g, b) # part of grosser.it/2011/09/16/ruby-converting-html-colors-24bit-to-xtermterminal-colors/ |
function lsgems() { | |
rubyversion=$(ruby -v | cut -f2 -d' ' | sed 's/p/-p/') | |
gemroot=~/.rvm/gems/ruby-"$rubyversion"/gems | |
ls "$gemroot" | |
} | |
function cdgem() { | |
rubyversion=$(ruby -v | cut -f2 -d' ' | sed 's/p/-p/') | |
gemroot=~/.rvm/gems/ruby-"$rubyversion"/gems |
# http://ruby-doc.org/stdlib-1.9.3/libdoc/net/smtp/rdoc/Net/SMTP.html | |
require 'digest/md5' | |
require 'mime/types' | |
require 'net/smtp' | |
require 'optparse' | |
require 'ostruct' | |
require 'yaml' | |
class Emailer |
#!/usr/bin/ruby | |
#Returns an email dictionary that includes all of an emails headers as well as each part of the email | |
#You can reference which part of the email you'd like by its content type | |
#Ex: email['parts']['text/html'] will get you the text/html version of the email body | |
#You can reference headers by the header name | |
#Ex: email['headers']['To'] will return the value of the "to" field | |
def headers_and_parts(file_path) | |
headers = {} | |
file = File.new(file_path, "r") |
class A | |
@@class_var = 'aclassvar' | |
@class_instance_var = 'aclassinstancevar' | |
def initialize | |
@instance_var = 'ainstance_var' | |
end | |
def A.class_method |
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes", "#{@scope[:shallow_prefix]}", "#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :projects # => config/routes/projects.rb | |
namespace :admin do |
# Beginning Rubyists: simply run >> ruby hex-convertions.rb to see examples | |
# or use irb to build the code on the fly | |
# you can convert HEX to DEC using the method .to_i(base), | |
# which converts a string to a decimal number from the specified base number | |
puts "00".to_i(16) | |
puts "FF".to_i(16) |
require 'pathname' | |
require 'fileutils' | |
#This assumes this script is your home directory level Rakefile | |
namespace :dotfiles do | |
desc "Link ALL the dotfiles!" | |
task :link do | |
path = Pathname.new("#{__FILE__}").dirname | |
Dir.glob "#{path}/Dotfiles/*" do |f| |
Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
module Resourceful | |
def self.actions | |
[:index, :show, :new, :edit, :create, :update, :destroy] | |
end | |
def self.callbacks | |
[:before, :after, :respond_to] | |
end |