Skip to content

Instantly share code, notes, and snippets.

Avatar

Francesco Sardo frankiesardo

View GitHub Profile
@frankiesardo
frankiesardo / core.cljs
Created Feb 7, 2020
stop.worry/love-js
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
ILookup
(-lookup
([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]]
[cljsjs.react.dom]
[goog.object :as obj]))
(enable-console-print!)
(extend-type object
ILookup
(-lookup
View helper.cljc
(ns react.helper
#?(:cljs (:require [cljsjs.react]
[cljsjs.create-react-class])))
#?(:cljs
(defn- react-factory [display-name render]
(js/React.createFactory
(js/createReactClass
#js {:displayName display-name
:shouldComponentUpdate
@frankiesardo
frankiesardo / request.sh
Last active Jun 11, 2020
Clojure deps one liners
View request.sh
clojure -Sdeps '{:deps {clj-http {:mvn/version "3.10.1"}}}' -e '(use (quote clj-http.client)) (get "http://google.com")'
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])]
(cond
(= p t)
(do
(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)))))