Give up on time units. Estimate of a task's duration should look like this:
- School exercise
- School homework
- School project
- Small contract
- Big contract
- Manhattan project
And an estimate of a task's difficulty should look like this:
(js/setInterval | |
#((do | |
(println 3) | |
(println 4))) | |
1000) | |
;; This logs 3 and 4 to the console, and then throws the error: | |
;; Uncaught TypeError: Cannot read property 'call' of null |
Give up on time units. Estimate of a task's duration should look like this:
And an estimate of a task's difficulty should look like this:
def assert_equals(a, b) | |
if a == b | |
puts "Hooray!" | |
else | |
puts "It wasn't what you wanted!" | |
end | |
end | |
class Object |
class Hash | |
def decompose | |
each_pair.each_with_index.each_with_object([{},{}]) { |((k,v), i), (f, s)| f[k], s[i] = i, v } | |
end | |
def decompose_to_a | |
each_pair.each_with_index.each_with_object([{},[]]) { |((k,v), i), (f, s)| f[k], s[i] = i, v } | |
end | |
end | |
{:a => "hello", :b => "world"}.decompose |
# Please add this to all your Ruby applications | |
class Array | |
# return an array containing all but the last element | |
def butlast | |
[0..-2] | |
end | |
# returns an array containing all but the first element | |
def rest | |
[1..-1] |
puts "hello" | |
# refactor to a method call | |
def hello | |
puts "hello" | |
end | |
hello | |
#refactor to invert control |
# Since a key-value store is a finite, discrete function, and functions | |
# can be composed, then Hashes can be composed. | |
# | |
# The syntactic sugar for calling lambdas, accessing array values, and | |
# other objects which have a #[] method allow composition of Hashes | |
# with all sorts of objects and contexts with the same implementation. | |
# | |
# Play with it at https://eval.in/388458 | |
# | |
class Hash |
def multiply(f, m) | |
x = f[0][0]*m[0][0] + f[0][1]*m[1][0] | |
y = f[0][0]*m[0][1] + f[0][1]*m[1][1] | |
z = f[1][0]*m[0][0] + f[1][1]*m[1][0] | |
w = f[1][0]*m[0][1] + f[1][1]*m[1][1] | |
[[x,y],[z,w]] | |
end |
def sum_diagonals(m) | |
next_i = 1 | |
r = [m[0][0]] | |
until next_i == m[0].size | |
i = next_i | |
j = 0 | |
r[next_i] = 0 | |
until i < 0 | |
r[next_i] += m[i][j] |