Skip to content

Instantly share code, notes, and snippets.

View ajbeach2's full-sized avatar
🏖️
skrrt skrrt

Alex ajbeach2

🏖️
skrrt skrrt
View GitHub Profile
@ajbeach2
ajbeach2 / test.perl
Created October 22, 2014 17:29
does something
@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
@ajbeach2
ajbeach2 / gist:c85f53a54d5c49880936
Created December 10, 2014 06:38
won't build tests
$ 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
def tt(t)
10.times do
puts t.call
end
end
def time
Time.now
end
t = Proc.new { time }
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
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
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
expect(
test_app('foo',
'example.com',
'/foo/bar'
).instance_id
).to eq('example_com_at_foo_bar')
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
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)
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