Skip to content

Instantly share code, notes, and snippets.


Scarlet Dame pleasetrythisathome

  • Penny and Damed Inc
  • Brooklyn, NY x New Orleans, LA
View GitHub Profile
View chsk.cljc
(ns populace.web.chsk
(:require #?@
[[aleph.http :as http]
[bidi.bidi :refer (path-for RouteProvider tag)]
[bolt.authentication :refer :all]
[bolt.authentication.protocols :refer (RequestAuthenticator)]
[byte-streams :as bs]
[hara.event :refer :all]
[ring.middleware.transit :refer [encode decode]]
View parser.cljc
(ns populace.parser
(:refer-clojure :exclude [read])
(:require [populace.user :as user]
[ :as parser]
[#?(:clj juxt.datomic.extras
:cljs populace.utils.datascript)
:refer (DatomicConnection as-conn as-db to-ref-id to-entity-map)]
[[populace.auth.client :refer :all]
[populace.config :refer [config filter-cljs]]
View markov.clj
(defn markov-data
(->> words
(partition 2 1)
(reduce (fn [acc [w next-w]]
(update-in acc
[w next-w]
(fnil inc 0)))
pleasetrythisathome / async_protocol.clj
Last active Aug 29, 2015
asynchronous "protocol" handshakes
View async_protocol.clj
(ns async-protocol
(:require [clojure.core.async :as async]
[clojure.set :as set]
[com.stuartsierra.component :as component :refer (Lifecycle)]
[taoensso.timbre :as log]))
(defn throw-err [e]
(when (instance? Throwable e) (throw e))
pleasetrythisathome / rum_cmp.cljs
Last active Aug 29, 2015
rum component system
View rum_cmp.cljs
(defprotocol IRender
(renderer [_])
(render-fn [_ views]))
(defprotocol IRumView
(display-name [_])
(state? [_])
(mixins [_]))
(defn rum-ctor [view]
pleasetrythisathome / kargs.clj
Created Mar 13, 2015
variadic keyword args or map or no-args
View kargs.clj
(defn kargs
([] (kargs {}))
([a b & {:as r}]
(kargs (assoc r a b)))
([a] a))
(and (= (kargs :some 1 :me 2)
(kargs {:some 1 :me 2})
{:some 1 :me 2})
(= (kargs)
pleasetrythisathome / clojure-repls.el
Created Mar 12, 2015
clojure-repls for component systems. automatically eval in correct buffer
View clojure-repls.el
;;; clojure-repls.el --- Assign repls for clj and cljs eval
;; Copyright (C) 2015 Dylan Butman
(require 'cider)
(require 'dash)
(defvar clojure-repls-clj-con-buf nil)
(defvar clojure-repls-cljs-con-buf nil)
pleasetrythisathome / poller.clj
Last active Aug 29, 2015
canonical component validation example
View poller.clj
(ns poller
[clojure.core.async :as async :refer (chan alts! go-loop timeout >! close!)]
[clojure.core.async.impl.protocols :as impl]
[com.stuartsierra.component :as component]
[plumbing.core :refer :all :exclude [update]]
[schema.core :as s]))
(defn poll!
"executes f at frequency and puts the result on output-chan, returns a stop functions"
View transition.cljs
(ns utils.transition
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [cljs.core.async :as async :refer [<! put! chan sub timeout]]
[plumbing.core :refer [update map-vals] :refer-macros [defnk fnk fn->]]
[bardo.ease :as ease]
[bardo.interpolate :as intrpl]
[cljs-time.core :as t]
[cljs-time.coerce :as tc]
[om.core :as om :include-macros true]
[om-tools.core :refer-macros [defcomponentk]]
pleasetrythisathome / debounce.clj
Last active Sep 3, 2015
debounce an action on a channel for values that produce the same result of a key-fn
View debounce.clj
(defn debounce
"debounce an action on a channel for values that produce the same result of a key-fn"
([f input-ch wait] (debounce f input-ch wait identity))
([f input-ch wait key-fn]
;; keep a map of keys that have been triggered
(go-loop [debounced {}]
(let [[v c] (alts! (conj (vals debounced) input-ch))]
(if (= c input-ch)
(let [key (key-fn v)]
(if (get (into #{} (keys debounced)) key) ;; if our key is debounced