- watch for ActiveRecord Relation, like
has_many
,has_many :through
- watch for
user_roles
, `group_users - UPDATE
action
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
def swap_string(string) | |
i = 0 | |
j = string.length - 1 | |
while i < j do | |
string[i] = (string[i].ord ^ string[j].ord).chr | |
string[j] = (string[i].ord ^ string[j].ord).chr | |
string[i] = (string[i].ord ^ string[j].ord).chr | |
i+=1 | |
j-=1 |
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
$VERBOSE = nil | |
require File.expand_path('../rooby', __FILE__) | |
Person = Rooby::Class.new 'Person' do | |
define :initialize do |name| | |
@name = name | |
end | |
define :name do |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"runtime" | |
"sync" | |
"time" |
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
natural_primer = ->(number) { | |
primes = [1] | |
number.times do | |
next_prime = primes.reduce(:*) + 1 | |
primes << next_prime | |
end | |
puts primes[1..-1].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
# A password hashing function insipred by Lamport OTP (a.k.a. hash chains) | |
# Memory factor: length of the Lamport OTP sequence | |
# Compute factor: number of independent Lamport OTP sequences to compute | |
# Hash: a keyed hash function | |
# | |
# Finally, all of the Lamport OTP chains calculated are concatenated and hashed | |
# to produce the resulting digest | |
# | |
# Just for fun, this has been implemented with threads to demonstrate how easily | |
# it can be parallelized, much like CTR mode (NOTE: you will need JRuby or Rubinius |
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 :rubygems | |
gem 'rails', '3.0.4' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'pg' | |
gem 'ar-octopus', :git => 'git://github.com/tchandy/octopus.git', :require => "octopus" |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<appSettings> | |
<!-- | |
According with the number used on the property | |
ServersNumber the bootstrapper will fetch this XML | |
and look for servers to initialize | |
--> | |
<add key="ServersNumber" value="1" /> | |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
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
--type-add=css=.sass,.less,.scss | |
--type-add=ruby=.rake,.rsel,.builder,.thor | |
--type-add=html=.haml,.html.erb,.html.haml | |
--type-add=js=.js.erb,.coffee | |
--type-set=cucumber=.feature | |
--type-set=c=.c,.cpp,.ino,.pde,.h | |
--ignore-dir=vendor | |
--ignore-dir=log | |
--ignore-dir=tmp | |
--ignore-dir=doc |