Skip to content

Instantly share code, notes, and snippets.

View acobster's full-sized avatar

Coby Tamayo acobster

View GitHub Profile
@spacegangster
spacegangster / typography.clj
Created January 28, 2021 10:32
Simple Clojure typography transformations for English, French, and Russian typography styles.
(ns common.typography
"Improve quotes and make whitespace non-breaking after 1-2 letter words"
(:require [clojure.string :as str]))
(def typo-replace-starting-nbsp
[#"(^[a-zA-Z\u0400-\u0500]{1,2})\ ", "$1 "])
(assert (= "A&nbsp;being in Australia <a class='yoy'>"
(apply str/replace "A being in Australia <a class='yoy'>" typo-replace-starting-nbsp)))
@roman01la
roman01la / index.md
Last active January 7, 2020 09:03
Abusing constants table in ClojureScript's compiler

Abusing constants table in ClojureScript's compiler

In React wrapper library UIx that I'm working on there's defui macro that compiles Hiccup directly into React's VirtualDOM. Apart from doing that the macro also hooks into the compiler to hoist constant parts of VirtualDOM across components and namespaces, so that those parts will be essentially interned (cached).

Here's an example of two components defined in different namespaces where both of them share a part of the structure.

(ns foo.core
  (:require [uix.core.alpha :refer [defui]]))
@acobster
acobster / .bashrc
Last active April 18, 2019 20:36
evil
# evil cowsay cd
cd_() { if [ "$((1 + RANDOM % 10))" = 3 ]; then _out="I'm sorry $(whoami), I can't do that for you."; $(if [ $(which cowsay) ]; then echo cowsay; else echo echo; fi) "$_out"; else cd; fi }
alias cd='cd_'
@rain-1
rain-1 / closure-conversion.rkt
Created February 16, 2019 10:06
Closure Conversion
#lang racket
;; this is a stand alone simple version of the closure conversion part of the hoist pass from the tarot compiler
;; see https://rain-1.github.io/scheme for more.
(require data/queue)
;; closure conversion for lambda calculus
;;
;; the input language is:
@eerohele
eerohele / xslt.clj
Last active October 15, 2020 05:26
Write XSLT with Clojure
(ns clj-xslt
(:require [clojure.data.xml :as xml])
(:import (java.time LocalDateTime)
(java.time.format DateTimeFormatter)
(java.io StringBufferInputStream StringWriter StringReader)
(javax.xml.transform.stream StreamSource)
(net.sf.saxon.s9api XsltCompiler Processor)
(net.sf.saxon Configuration)))
(def processor