Skip to content

Instantly share code, notes, and snippets.

Martin Klepsch martinklepsch

Block or report user

Report or block martinklepsch

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
martinklepsch /
Last active Apr 7, 2017
Trying to compile some common JS patterns and their respective ways to extern them for Closure advanced compilation
// plain function
function add_one(x) {
  return 1 + x;

// constructor
MyClass = function(name) {
  this.myName = name;
martinklepsch / rum_system.cljs
Created Jan 13, 2017
Rum components to start/stop com.stuartsierra.component systems and inject them into React context.
View rum_system.cljs
(ns org.martinklepsch.rum-system
"Rum components to start/stop com.stuartsierra.component systems and inject them into React context."
(:refer-clojure :exclude [comp])
(:require [rum.core :as rum]
[goog.object :as gobj]
[com.stuartsierra.component :as component]))
(def context-k (-> (str ::get-sys) (subs 1)))
(def context-types {context-k js/React.PropTypes.func})
martinklepsch / oop-hickey.markdown
Created Jan 2, 2017
Rich Hickey on object systems
View oop-hickey.markdown

Originally posted on the mailinglist here. Mostly copied it here so I can add it to Pocket.

Here are some problems/limitations of existing OO/GF systems that I don't intend to repeat:

A) They provide only a single declaration point for all superclasses of a class B) They consider the local declaration order of superclasses to be

martinklepsch / login_blocking.markdown
Last active Oct 10, 2019
`login` blocking indefinitely
View login_blocking.markdown

More context:

$ sudo dtruss login
dtrace: system integrity protection is on, some features will not be available
dtrace: failed to execute login: dtrace cannot control executables signed with restricted entitlements

In my ~/.tmux.conf I had a line like this:

set-option -g default-command "reattach-to-user-namespace -l fish"
martinklepsch / core.cljc
Last active Dec 20, 2017
A form validation system for ClojureScript using funcool/struct. Besides plain validation it also has some support for showing validation issues only after the user has completed (on-blur) their input. That means the validation is not running eagerly with limited user input.
View core.cljc
;; This was an earlier attempt using clojure.spec. I discarded it for reasons I don't remember.
(ns forms.core
#?(:cljs [cljs.spec :as s]
:clj [clojure.spec :as s])))
;; (s/def ::form-state
;; {::value s/Any
;; ::initial-value s/Any
;; ::errors s/Any


A note on terminology: There are a lot of things with similar meanings/use-cases around: subscriptions, reactions, derived atoms, view models. I'll introduce another to make things even worse: derivative. A derivative implements IWatchable and it's value is the result of applying a function to the value of other things (sources) implementing IWatchable. Whenever any of the sources change the value if the derivative is updated.

Why this library

Let's assume you're hooked about the idea of storing all your application state in a single atom (db). (Why this is a great idea is covered elsewhere.)

Most of your components don't need the entirety of this state and instead receive a small selection of it that is enough to allow the components to do their job. Now that data is not always a subtree (i.e. (get-in db ...)) but might be a combination of various parts of your state. To transform the data in a way that it becomes useful for components you can use a function: `(f @

View sqs.clj
(:require [ :as sqs]
[com.stuartsierra.component :as component]
[ :as s]
[manifold.time :as t]
[manifold.deferred :as d]
[environ.core :as e]))
(def creds
{:access-key (e/env :aws-access-key)
View reagent-autoscroll.cljs
;; Auto-scrolling ==============================================================
(defn scroll! [el start end time]
(.play (goog.fx.dom.Scroll. el (clj->js start) (clj->js end) time)))
(defn scrolled-to-end? [el tolerance]
;; at-end?: element.scrollHeight - element.scrollTop === element.clientHeight
(> tolerance (- (.-scrollHeight el) (.-scrollTop el) (.-clientHeight el))))
(defn autoscroll-list [{:keys [children class scroll?] :as opts}]
View _flag.sass
// The flag object shares a lot of common traits with the media
// object; its sole purpose is displaying image- and text-like content
// side-by-side. Where the flag object differs, however, is its ability
// to vertically align the image and text to the tops, middles or bottoms
// of each other.
display: table
View with-dir.clj
(defn same-val [m]
(-> (fn [nm [k v]]
(let [in-other? (-> (dissoc m k) vals set)]
(if (in-other? v)
(assoc nm k v)
(reduce nil m)))
(defn dir-scoper
You can’t perform that action at this time.