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
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{ | |
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord | |
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&& | |
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print |
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
$ cmake .. -DPREFIX=~/Workspace/weechat -DENABLE_TESTS=ON -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-4.9 -DCMAKE_C_COMPILER=/usr/local/bin/gcc-4.2 | |
-- The C compiler identification is GNU 4.2.1 | |
-- Checking whether C compiler has -isysroot | |
-- Checking whether C compiler has -isysroot - yes | |
-- Checking whether C compiler supports OSX deployment target flag | |
-- Checking whether C compiler supports OSX deployment target flag - yes | |
-- Check for working C compiler: /usr/local/bin/gcc-4.2 | |
-- Check for working C compiler: /usr/local/bin/gcc-4.2 -- works | |
-- Detecting C compiler ABI info | |
-- Detecting C compiler ABI info - done |
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 tt(t) | |
10.times do | |
puts t.call | |
end | |
end | |
def time | |
Time.now | |
end | |
t = Proc.new { 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
def fib(x, sequence = []) | |
if x <= 1 | |
result = 1 | |
elsif | |
result1 = sequence[x - 1] ||= fib(x - 1) | |
result2 = sequence[x - 2] ||= fib(x - 2) | |
result = result1 + result2 | |
end | |
sequence[x] = result | |
return result |
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 fib_fast(x , storage) | |
result = 0 | |
if x == 0 | |
result = 0 | |
elsif x == 1 | |
result = 1 | |
else | |
if storage[x] | |
result = storage[x] | |
else |
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 fib_mod(a,b,x,sequence = []) | |
if x == 1 | |
result = a | |
elsif x == 2 | |
result = b | |
else | |
result1 = sequence[x - 1] ||= fib_mod(a,b,x - 1, sequence) | |
result2 = sequence[x - 2] ||= fib_mod(a,b,x - 2, sequence) | |
result = result1**2 + result2 | |
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
expect( | |
test_app('foo', | |
'example.com', | |
'/foo/bar' | |
).instance_id | |
).to eq('example_com_at_foo_bar') | |
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 Domain < ActiveRecord::Base | |
validate :valid_domain, on: :create | |
def valid_domain | |
errors.add(:name, "domain is not valid!") unless my_domain_check_methond(name) | |
end | |
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 DomainValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
unless domain_check(value) | |
record.errors[attribute] << (options[:message] || "is not a valid domain") | |
end | |
end | |
def domain_check(name) | |
input = PublicSuffix.parse(name) | |
domain = input.domain | |
PublicSuffix.valid?(domain) |
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 Runnable | |
def run(command, *args) | |
fail "#{command} is not a valid action!" unless actions.include? command | |
send(command, *args) | |
end | |
def runnables(*args) | |
define_singleton_method(:actions) do | |
args.map(&:to_s) | |
end |
OlderNewer