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
class CreateJoinTableForDomainsAndUsers < ActiveRecord::Migration | |
def change | |
create_table :domains_users, id: false do |t| | |
t.integer :user_id | |
t.integer :domain_id | |
end | |
add_index :domains_users, [:user_id, :domain_id] | |
add_index :domains_users, [:domain_id, :user_id] | |
end | |
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 'openssl' | |
require 'base64' | |
secret_message = 'foo!' | |
aes = OpenSSL::Cipher.new 'AES-256-CBC' | |
aes.encrypt | |
iv = aes.random_iv # never EVER use the same IV if you're reusing a key | |
rnd = aes.random_key |
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
:%s/{/(/g|%s/}/)/g | |
jr}w./[ | |
r{jj.kF(r[f)r]ZZ |
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
### Without libpng installed | |
$ brew install -v povray | |
==> Build Environment | |
CC: /usr/bin/cc => /usr/bin/gcc-4.2 | |
CXX: /usr/bin/c++ => /usr/bin/c++-4.2 | |
LD: /usr/bin/cc => /usr/bin/gcc-4.2 | |
CFLAGS: -O3 -w -pipe | |
CXXFLAGS: -O3 -w -pipe | |
MAKEFLAGS: -j4 |
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
scope :latest_by_hashtag, lambda {|hashtag| { | |
:where => { :hashtags => hashtag }, | |
:order_by => :tweeted_at.desc, | |
:limit => 20 } | |
} | |
# OR # | |
module MyModelModules | |
module Scopes |
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
source :rubygems | |
gem 'rails' | |
# Or find something else that returns true | |
# locally, but false on heroku | |
if RbConfig::CONFIG['host_os'] =~ /darwin/ | |
group :test do | |
# heroku fails hard on this gem | |
gem 'specjour' |
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
source :rubygems | |
gem 'activerecord', '2.3.5' | |
gem 'sqlite3-ruby' |
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
STRIPPED_PS1="$(echo "$PS1" | sed -e 's/\$ $//')" | |
function prompt_with_success { | |
previous_return_value=$? | |
RED="\[\033[0;31m\]" | |
GREEN="\[\033[0;32m\]" | |
COLOR_NONE="\[\e[0m\]" | |
if [ $previous_return_value -eq 0 ] |
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
module Submethods | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def submethods type = :public | |
if self.class.name == "Object" | |
return nil | |
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
Shoes.setup do | |
gem 'activeresource' | |
end | |
require 'activeresource' | |
class Person < ActiveResource::Base | |
self.site = 'http://0.0.0.0:3000' | |
end |