Skip to content

Instantly share code, notes, and snippets.


Francesco Sardo frankiesardo

View GitHub Profile
frankiesardo / core.cljs
Created Feb 7, 2020
View core.cljs
(ns stop-worry.core
(:require ["react" :as react :rename {createElement $}]
["react-dom" :as dom]
[goog.object :as obj]
[cljs.core.async :as async]))
(extend-type object
([o k] (obj/get o (name k)))
View react.helper.clj
(ns react.helper)
(defmacro defc [name argv & body]
`(def ~name (react.helper/component (str '~(get-in &env [:ns :name]) "/" (name '~name)) (fn ~argv ~@body))))
View core.cljs
(ns example.core
(:require [react.helper :refer-macros [defc]]
[goog.object :as obj]))
(extend-type object
View helper.cljc
(ns react.helper
#?(:cljs (:require [cljsjs.react]
(defn- react-factory [display-name render]
#js {:displayName display-name
frankiesardo /
Last active Jun 11, 2020
Clojure deps one liners
clojure -Sdeps '{:deps {clj-http {:mvn/version "3.10.1"}}}' -e '(use (quote clj-http.client)) (get "")'
View README.adoc

AsciiDoc Writer’s Guide

Table of Contents

Header 1

Header 2

View batching.clj
(defn batch [in out max-time max-count]
(let [lim-1 (dec max-count)]
(async/go-loop [buf [] t (async/timeout max-time)]
(let [[v p] (async/alts! [in t])]
(= p t)
(async/>! out buf)
(recur [] (async/timeout max-time)))
View tinylog.clj
(ns tinylog.core
(:require [clj-http.client :as http]
[cheshire.core :as json]
[clojure.core.async :as async]))
(defprotocol Logger
(log [this msg]))
(defn map* [f logger]
(reify Logger
View log.clj
(ns example.log)
(defprotocol Logger
(log [this msg]))
(defn map* [f logger]
(reify Logger
(log [this msg] (log logger (f msg)))))