Skip to content

Instantly share code, notes, and snippets.

@shapiy
shapiy / .versionrc.js
Created October 12, 2021 12:41
standard-version updater for Leiningen project.clj
// standard-version updater to read and write project version from/to Leiningen project.clj.
const defProjectRegex = /\(defproject\s+([a-z\./-]+)\s+\"([^\"]+)\".*/;
module.exports = {
bumpFiles: [{
filename: 'project.clj',
updater: {
readVersion: function(contents) {
const lines = contents.split("\n");
const defProject = lines[0];
@shapiy
shapiy / quintessence.clj
Last active May 7, 2020 07:34
A higher-order function to yield some sense in an arbitrary life situation, no matter how absurd, written in Clojure.
(defn quintessence
"Yields sense.
Should be used judiciously. Sense is not what you always want."
[]
(fn [anything] ((juxt :important :inevitable) anything)))
@shapiy
shapiy / clojure-xslt-1.clj
Last active November 4, 2019 11:57
Implementing XSLT-like transformation in bare Clojure: https://shapiy.github.io/blog/clojure-xslt/
(ns io.shapiy.core
(:gen-class)
(:require [clojure.data.xml :refer :all])
(:import (clojure.data.xml Element)))
(def html "<!DOCTYPE html>
<html>
<body>
<h1>Programming languages</h1>
<p>There are many, for example:</p>
@shapiy
shapiy / clojure-xslt-identity.clj
Last active November 4, 2019 11:57
Implementing XSLT-like transformation in bare Clojure: https://shapiy.github.io/blog/clojure-xslt/
(ns io.shapiy.core
(:gen-class)
(:require [clojure.data.xml :refer :all])
(:import (clojure.data.xml Element)))
(def html "<!DOCTYPE html>
<html>
<body>
<h1>Programming languages</h1>
<p>There are many, for example:</p>
@shapiy
shapiy / TraceXmlReader.java
Created June 28, 2016 18:54
XSLT SAXParser which inserts user trace calls in xsl:template instructions.
package rocks.xml.saxontrace;
import org.apache.xerces.parsers.SAXParser;
import org.apache.xerces.util.AugmentationsImpl;
import org.apache.xerces.util.XMLAttributesImpl;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XNIException;