I hereby claim:
- I am davidrupp on github.
- I am davidrupp (https://keybase.io/davidrupp) on keybase.
- I have a public key whose fingerprint is 99A3 E112 A4A4 96D1 64BB EB79 8D5F F86E 49D8 E7C5
To claim this, I am signing this object:
(def thing 1) ; value of thing is now 1 | |
; do some stuff with thing | |
(alter-var-root #'thing (constantly nil)) ; value of thing is now nil |
(def thing 1) | |
; do some stuff with thing | |
(def thing nil) | |
; value of thing is now nil |
(def thing 1) | |
; general form is | |
; (alter-var-root var-to-be-altered | |
; function-to-apply-to-old-value) | |
(alter-var-root #'thing inc) ; value of thing is now 2 | |
; equivalently ... | |
(alter-var-root #'thing (fn [old-val] (inc old-val))) ; value of thing is now 3 | |
; also equivalently ... | |
(alter-var-root #'thing #(inc %1)) ; value of thing is now 4 |
(def thing 1) | |
(alter-var-root #'thing (fn [old-val] nil)) ; value of thing is now nil | |
; we don't really need to name the argument, because we don't use it | |
; but we *do* need to include it; otherwise we'll get an arity exception | |
(alter-var-root #'thing (fn [_] nil)) ; value of thing is now nil | |
; equivalently (kind of) ... | |
(alter-var-root #'thing (constantly nil)) |
(#(identity %3) 1 2) | |
;=> ArityException Wrong number of args (2) passed to: user/eval3407/fn--3408 ... |
(def thing 1) | |
; these all happen to work, but ... yuck | |
(alter-var-root #'thing #(if %1 nil)) | |
(alter-var-root #'thing #(last [%1 nil])) | |
(alter-var-root #'thing #(do %1 nil)) |
I hereby claim:
To claim this, I am signing this object:
seconds = 356521 | |
days, hours, minutes, seconds = | |
[1.day, 1.hour, 1.minute, 1.second].inject([]) do |acc, unit| | |
quotient, seconds = seconds.divmod unit | |
acc << quotient | |
end |
#!/usr/bin/env ruby | |
require 'find' | |
Find.find("/Users/david/Developer") do |path| | |
Dir.chdir(path) do |d| | |
next unless File.exists? ("#{d}/.git") | |
puts d | |
`git pull` | |
Find.prune |
#!/usr/bin/env ruby | |
if ARGV.empty? | |
puts "Usage: gemmate <name-of-gem>" | |
else | |
src = `gem which #{ARGV[0]}`.split.last | |
lib_dir = src.slice 0, src.rindex("lib") | |
`mate -a '#{lib_dir}'` | |
end |