Skip to content

Instantly share code, notes, and snippets.

View streaming_20190310.md

Adding a higher level API to Trikl

Streaming Sunday afternoon at https://www.youtube.com/c/LambdaIsland/live

Towards the end of last year I created Trikl (https://github.com/lambdaisland/trikl), a library for building rich terminal interfaces that's modeled after Reagent. You write components using a variant of Hiccup, and trikl takes care of rendering them, applying smart diffing to minimize the amount of updates to send to the terminal, assuring updates always look smooth.

View invoice.rb
# coding: utf-8
$:.unshift '/home/arne/github/kramdown/lib'
require 'fileutils'
require 'prawn'
require 'kramdown'
require 'json'
CURRENCIES = {
'EUR' => '€ %.2f',
View clj_ns_buffer_names.el
;; Rename clj/cljs/cljc buffers to their namespace name, so you see
;; `foo.bar.core' in the modeline, rather than `core.clj'
(advice-add 'rename-buffer :around #'plexus/clj-ns--rename-buffer-advice)
(defun plexus/clj-ns--rename-buffer-advice (rb-fun newname &optional unique &rest args)
(let ((filename (buffer-file-name (current-buffer)))
(buf-start (buffer-substring-no-properties (point-min) (point-min))))
(if (and (string-match "\\.clj[cxs]?$" filename)
(string-match "(ns \\([^\n )]+\\)" buf-start))
(match-string-no-properties 1 buf-start)
View .emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (package-initialize)
(setq chemacs-profiles-path "~/.emacs-profiles.el")
(when (not (file-exists-p chemacs-profiles-path))
(with-temp-file chemacs-profiles-path
(insert "((\"default\" . ((user-emacs-directory . \"~/.emacs.d\"))))")))
View generate_docs
#!/bin/bash
# Keep a separate branch of generated API docs.
#
# This script generates API documentation, commits it to a separate branch, and
# pushes it upstream. It does this without actually checking out the branch,
# using a separate working tree directory, so without any disruption to your
# current working tree. You can have local file modifications, but the git index
# (staging area) must be clean.
View async.clj
(ns slacker.async)
(defmacro promise
"Creates a promise. Takes a binding form which binds the [resolve reject]
callbacks.
(promise [res rej]
(res 42))"
{:style/indent 1}
[bindings & body]
View async.clj
(ns slacker.async)
(defmacro promise
"Creates a promise. Takes a binding form which binds the [resolve reject]
callbacks.
(promise [res rej]
(res 42))"
{:style/indent 1}
[bindings & body]
View Code.gs
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
}
View webstack.clj
(ns lambdaisland.components.webstack
(:require [com.stuartsierra.component :as component]))
(defn stack-tier-handler
"Create the ring handler for a single stack tier"
[component {:keys [make-handler middleware using]}]
(reduce (fn [h mw]
(if (vector? mw)
(apply (first mw) h (rest mw))
(mw h)))
You can’t perform that action at this time.