Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Sam Ritchie sritchie

🎯
Focusing
Block or report user

Report or block sritchie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View macros.cljx
;; ## State Methods
(defmulti initial-state
"Multimethod that returns the initial state for the supplied
page." :name)
(s/defmethod initial-state :default [r :- Route s :- (s/maybe AppState)] {})
(defmulti page-title
"Returns the current page title for the supplied route." :name)
View errors.txt
WARNING: 3 error(s), 0 warning(s)
ERROR: JSC_BASE_CLASS_ERROR. incorrect use of goog.base: First argument must be 'this'. at /Users/sritchie/code/clojure/racehub.com/resources/public/assets/generated/racehub/om/router.js line 520 : 104
ERROR: JSC_BASE_CLASS_ERROR. incorrect use of goog.base: First argument must be 'this'. at /Users/sritchie/code/clojure/racehub.com/resources/public/assets/generated/racehub/om/router.js line 523 : 223
ERROR: JSC_BASE_CLASS_ERROR. incorrect use of goog.base: First argument must be 'this'. at /Users/sritchie/code/clojure/racehub.com/resources/public/assets/generated/racehub/om/router.js line 526 : 250
View error.clj
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)
at clojure.lang.RT.classForName(RT.java:2118)
at clojure.lang.RT.classForName(RT.java:2127)
at clojure.lang.RT.loadClassForName(RT.java:2146)
at clojure.lang.RT.load(RT.java:430)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5436.invoke(core.clj:5863)
at clojure.core$load.doInvoke(core.clj:5862)
View Facebook Login.md
  • 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 facebook.cljs
(ns racehub.om.facebook
(:require [cljs.core.async :as a]
[racehub.schema :as rs]
[schema.core :as s :include-macros true]))
;; ## Utilities
(defn prune
"Takes a mapping of keys -> new key names and a map and returns a
map with nils removed and keys swapped where they're present in the
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 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
fired.
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 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)}})))
@sritchie
sritchie / algebra.swift
Created Jun 9, 2014
Typeclasses in Swift
View algebra.swift
// Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
// Here's take 1. First, I defined the algebra like I would in
// Scala, as separate protocols:
protocol Semigroup {
typealias T
View injection.swift
import Cocoa
let x = "Face"
protocol Injection<T, U> {
func apply(T) -> U
func invert(U) -> T?
}
class IntInjection: Injection {
You can’t perform that action at this time.