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 "openssl" | |
require "digest" | |
def aes128_encrypt(key, data) | |
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize) | |
aes = OpenSSL::Cipher.new('AES-128-CBC') | |
aes.encrypt | |
aes.key = key | |
aes.update(data) + aes.final | |
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
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter :secure_with_ssl | |
private | |
def secure_with_ssl | |
if request.subdomain != 'secure' or request.protocol != 'https' | |
redirect_to :subdomain => 'secure', :protocol => 'https' |
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
#!/bin/bash | |
# oh god do I hate tooltips | |
defaults write -g NSInitialToolTipDelay -int 30000 | |
defaults write com.apple.dock pinning -string start | |
defaults write com.apple.dock autohide -boolean YES | |
defaults write com.apple.dock no-glass -boolean YES | |
defaults write com.apple.dock use-new-list-stack -boolean yes | |
defaults write com.apple.dock expose-animation-duration -float 0.15 |
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
module TransactionalFixtures | |
def run(*) | |
result = nil | |
DB.transaction(rollback: :always) { require 'fixtures'; result = super } | |
result | |
end | |
end | |
module Minitest | |
class << self |
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 'test/unit' | |
# or | |
# require "minitest" | |
# require "minitest/autorun" | |
class Test::Unit::TestCase | |
# or, for Minitest, do: | |
# class Minitest::Test | |
def self.testing(name) |
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
# Rack file for local Rubygems server, using YARD | |
require "rubygems" | |
require "yard" | |
libraries = {} | |
Gem.source_index.find_name('').each do |spec| | |
libraries[spec.name] ||= [] | |
libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem) | |
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
require 'rubygems' | |
require 'yard' | |
libs = {} | |
gems = {} | |
base = ENV['GEM_PATH'].split(':')[1][%r{^.+(?=/.+@global$)}] rescue nil | |
if base | |
Gem.paths = { | |
'GEM_PATH' => Dir["#{base}/ruby-*"].join(':'), |
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
module Mod | |
extend self | |
def one | |
"this is one" | |
end | |
def two | |
"this is two" | |
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
source 'http://rubygems.org' | |
gem 'sinatra', '1.3.1' | |
gem 'sinatra-sprockets', '0.0.2' |
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
describe_service "hello_world" do |service| | |
service.formats :json | |
service.http_verb :get | |
service.disable_auth # on by default | |
# INPUT | |
service.param.string :name, :default => 'World' | |
# OUTPUT | |
service.response do |response| |