- watch for ActiveRecord Relation, like
has_many,has_many :through - watch for
user_roles, `group_users - UPDATE
action
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
| 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 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 simplified version of Ruby's object system, implemented in Ruby. This only | |
| # supports a subset of Ruby, but is intended to accurately model inheritance | |
| # and method lookup in as little code as possible, for ease of understanding by | |
| # Ruby programmers. | |
| # | |
| # Classes implemented: | |
| # | |
| # * Object | |
| # * Module < Object | |
| # * Class < Module |
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
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| "runtime" | |
| "sync" | |
| "time" |
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
| 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 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 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 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
| var self = window; | |
| (function(self) { | |
| var canvas, context, particles = [], explode = true, FPS = 60; | |
| /* | |
| * Init. | |
| */ | |
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 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 ApplicationController < ActionController::Base | |
| caches_action :render_html, | |
| :cache_path => Proc.new { "#{LastChange::last_update}/pages/#{params[:cms_path]}" }, | |
| :if => Proc.new { controller_name == "cms_content" } | |
| 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
| public class Test { | |
| @Assertion("foo>0") | |
| int foo=1; | |
| @Assertion("bar%2==0") | |
| long bar; | |
| @Assertion("baz>foo") | |
| int baz; |
NewerOlder