Skip to content

Instantly share code, notes, and snippets.

View currentoor's full-sized avatar

Karan Toor currentoor

  • Temecula, California
View GitHub Profile
@currentoor
currentoor / quotes.clj
Last active August 29, 2015 14:23
Quoting Confusion
'x
;x
''x
;(quote x)
'''x
;(quote (quote x))
`x
;yaadapp.core/x
(defn ->kebab [s]
(str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s))))
(def components '[Card
AppBar
LeftNav
CardTitle])
(defn gen-wrapper [component]
`(defmacro ~(symbol (->kebab (str component))) [& args#]
(def app-wrapper
(let [colors js/window.MaterialUI.Styles.Colors
yaad-theme #js {:getPalette (fn [] #js {:primary1Color (.-green800 colors)
:primary2Color (.-green700 colors)
:primary3Color (.-green600 colors)})
:getComponentThemes (fn [_] #js {})}
theme-manager (js/window.MaterialUI.Styles.ThemeManager.)]
(js/React.createClass
#js {:childContextTypes #js {:muiTheme js/React.PropTypes.object}
:getChildContext (fn []
(ns yaadapp.material
(:require [clojure.string :as str]
[clojure.walk :as walk]))
(defn ->kebab [s]
(str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s))))
(def components '[AppBar
Card
CardActions
(def macro-state
(atom {:question ""
:answer ""}))
(defcc input-wrapper < rum/reactive [comp hint label ref]
(mui/text-field {:hintText hint
:multiLine true
:fullWidth true
:rows 2
:value (rum/react ref)
(defn- average [coll]
(/ (reduce + coll) (count coll)))
(let [paid {:karan 900
:chirag 50
:jindi 400
:harleen 200
:sukh 100
:raman 10}
@currentoor
currentoor / reset_component.clj
Last active January 11, 2016 23:21
Reset the components of an entity without worrying about the current values or their entity-ids.
(defn reset-components [db eid attr new-comps]
(let [current-comps (-> (d/pull db [attr] eid) attr)
;; First we do a value based comparison ignoring component entity ids.
current-comp-vals (into #{} (map #(dissoc % :db/id) current-comps))
new-comp-vals (into #{} new-comps)
deletions (clojure.set/difference current-comp-vals new-comp-vals)
additions (clojure.set/difference new-comp-vals current-comp-vals)
(ns arc.router
(:require
[om.next :as om]
[bidi.bidi :as bidi]))
(extend-protocol bidi/PatternSegment
function
(segment-regex-group [this]
(condp = this
keyword "[A-Za-z]+[A-Za-z0-9\\*\\+\\!\\-\\_\\?\\.]*(?:%2F[A-Za-z]+[A-Za-z0-9\\*\\+\\!\\-\\_\\?\\.]*)?"
(ns ucv.semantic-ui.factories
(:require ["semantic-ui-react" :as semantic-ui]
goog.object))
(defn factory-apply
[class]
(fn [props & children]
(apply js/React.createElement
class
(clj->js props)
(ns ucv.server.websocket-channel-listener
(:require
[fulcro.websockets.protocols :refer [WSListener add-listener remove-listener]]
[mount.core :refer [defstate args]]
[taoensso.timbre :as log]
[ucv.server.websockets :refer [websockets]]))
;;; Fulcro's component sticks the result of user-id-fn into the top level of
;;; env, for mutations to use.