Skip to content

Instantly share code, notes, and snippets.

class AssignCaseCommand < Command
attribute :case, Case
attribute :owner, User
attribute :created_by, User
attribute :comments, String
attribute :distribute_at, DateTime
attribute :distribute_rule_name, String
attribute :require_initial, Boolean
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
def get_lineno(iseq, pos):
if pos != 0:
pos -= 1
@benolee
benolee / a.rb
Last active August 29, 2015 14:01 — forked from ahoward/a.rb
# make this script run, update your gist with the running script, and it's
# output in a separate gist. the entire quzi should take 1-3 minutes, but you
# get 5.
#
# the meat - take < 5 minutes to do this
#
assert :hash do
x = x.to_h
# fyi: I have no idea what I'm doing :)
Log = Struct.new :buffer do
def call method
buffer << "Log: before #{method.name}\n"
method.call buffer
buffer << "Log: after #{method.name}\n\n"
self
end
end

monads are an abstraction

objects are an abstraction

They're two very different abstractions :-)

In my opinion, monads are much simpler than objects.

Because monads are only abstractions of structure, where you get to change the meaning yourself. >

puts "toplevel Module nesting: #{Module.nesting.inspect}"
class Foo
def bar
puts "hello from Foo#bar"
end
end
::ExportedFoo = Foo
I = -> x { x }
C = -> x { -> y { -> z { x[z][y] } } }
T = -> C[I]
K = -> x { -> y { x } }
U = -> f { f[f] }
# I know, this technically isn't the Y combinator,
# and it isn't exactly the Z combinator either (like Y, but for applicative order languages).
Y = -> g { U[-> f { -> x { g[U[f]][x] } } ] }
@benolee
benolee / Wat.hs
Last active August 29, 2015 14:04
-- Exercise 1
-- converts positive Integers to a list of digits.
toDigits :: Integer -> [Integer]
toDigits x = reverse (toDigitsRev x)
toDigitsRev :: Integer -> [Integer]
toDigitsRev x
| x <= 0 = []
| otherwise = (mod x 10) : toDigitsRev (div x 10)
def enum blk = Proc.new
m = Module.new
o = Object.new
o.instance_eval {
@enum_idx = -1
@enum_mod = m
def method_missing(n, *a)
n =~ /([A-Z][A-Z_]*)(=)?/
raise "bad enum name #{n}" unless $1
if $2