Skip to content

Instantly share code, notes, and snippets.


Sam Ritchie sritchie

View GitHub Profile
View flatmap.clj
(defn flatmap<
"Takes a function and a source channel, and returns a channel which
contains the values in each channel produced by applying f to
each value taken from the source channel. f must return a
[f in]
(let [out (a/chan)]
(a/go-loop []
(let [item (a/<! in)]
(if (nil? item)
View signup.clj
(defn attempt-registration
"Friend workflow that tries to register a user; only works if a
user's gone to the signup page. Proper form validations are all
applied. If these all pass, the user is created and logged in, and
the redirection occurs."
[{:keys [uri request-method params session]}]
(when (and (= uri "/signup")
(= request-method :post))
(v/if-valid signup-validator
View transfer_response.clj
{:description "xxx Transfer",
:amount xxxxx,
:date 1400198400,
:recipient "recip",
:type "bank_account",
:created 1400110536,
{:disabled false,
:bank_name "WELLS FARGO BANK",
:last4 "xxxxx",
View ssl.clj
At Wed May 21 03:40:12 UTC 2014 ()
Tags: [exception]
Custom Attributes: {:request-id "14c631b8-027e-44f4-9ab4-3deba9843626", :exception ""} peer not authenticated 371
org.apache.http.conn.ssl.AbstractVerifier.verify 128
org.apache.http.conn.ssl.SSLSocketFactory.connectSocket 572
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection 180
View injection.swift
import Cocoa
let x = "Face"
protocol Injection<T, U> {
func apply(T) -> U
func invert(U) -> T?
class IntInjection: Injection {
View cursor.clj
(let [pricing (:pricing static)
cursor (map (fn [e]
{:event e
:pricing pricing
:selection (-> dynamic :entries (get (:id e)))
:payment-method :credit-card})
(:events static))]
(d/div {} (om/build-all event-row cursor
{:init-state {:update (:update @state)}})))
View autocomplete.cljs
(defcomponentk address-field
"The address field uses Google Places autocomplete
internally. Autocomplete has some issues with onChange and onBlur;
after clicking one of the options in the dropdown (instead of
tabbing away), the field won't update until after onBlur has
This component gets around that issue by waiting until the
`place_changed` event is fired by the Autocomplete widget, and only
then reading the value of the original input component.
View coupon.cljs
(sm/defn coupon-lookup
"If the code supplied is empty, sends a failed discount on
immediately. (This won't affect the rendering, since nothing's
shown if the code is blank.) If the code is NOT blank, fires off an
Ajax request to the server to look up the discount.
TODO: Ideally we'd have a channel that could signal a dissoc,
instead of only adding items to the state."
[title :- regatta/Title
code :- coupon/Code
View Facebook
  • user signs up with email and password:

    • if the email exists, validation error.
    • if the email is linked to a facebook account, they'll see the "merge?" box when they try to link later
    • if the email doesn't exist, create the account!
      • Username is auto-generated
      • we send a welcome! email
      • we send a verification email
  • user decides to link a Facebook account:

    • when the user clicks on the "Link Facebook" link in profile, login with javascript SDK
View error.clj
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at clojure.lang.RT.classForName(
at clojure.lang.RT.classForName(
at clojure.lang.RT.loadClassForName(
at clojure.lang.RT.load(
at clojure.lang.RT.load(
at clojure.core$load$fn__5436.invoke(core.clj:5863)
at clojure.core$load.doInvoke(core.clj:5862)