Skip to content

Instantly share code, notes, and snippets.

@tylerperkins
tylerperkins / inductive-proof.md
Last active March 3, 2018 23:28
Demo of proving a proposition by induction

The sum of all natural numbers from 0 to n is

sum(n) = n*(n+1)/2

Proof

  • Base case: Is it true for sum(0)?

    sum(0) = 0(0+1)/2 = 0
    

Using owlet.firebase

Namespace owlet.firebase serves to integrate a Firebase database into our re-frame web application. We need to talk to Firebase without dropping into evil JS interop — so you shouldn't use .set! But more generally, we must preserve the integrity of our application's re-frame data flow.

re-frame data flow

In the description below, I've tried to be entirely consistent in my use of names; i.e. the scope of any name is this entire document. So when you see your-value or the-db-ref, you can count on those names indicating the same entities when they appear later in the document. Also, "ref" or "reference" refers to an instance of [firebase.database.Reference](https://firebase.google.com/docs/reference/js/firebase.database.Refe

@tylerperkins
tylerperkins / threading_macros.clj
Created March 18, 2011 22:18
The -> and ->> macros are enough!
;; Let's say you have a map recording the number of siblings for each individual:
(def num-sibs {:jack 0, :jill 2, :jane 0, :spot 7})
;; Say you want to find the number of only children. We can use ->>
(->> num-sibs
(map val)
(filter zero?)
count)