Skip to content

Instantly share code, notes, and snippets.

Avatar
🧙‍♂️
(magic)

Oliver Caldwell Olical

🧙‍♂️
(magic)
View GitHub Profile
@Olical
Olical / conjure-school.sh
Created Aug 2, 2020
Conjure school without installing Conjure!
View conjure-school.sh
# Try an interactive Conjure tutorial without installing Conjure!
# All you need is curl and an up to date nvim.
curl -fL conjure.fun/school | sh
@Olical
Olical / repair.clj
Created Oct 15, 2019
Repair translated Markdown -> AsciiDoc files from my blog
View repair.clj
(require '[clojure.string :as str]
'[clojure.edn :as edn])
(for [file (fs/list-dir "posts")
:when (str/ends-with? (str file) ".md.adoc")]
(let [[_ date slug] (re-find #"(\d\d\d\d\-\d\d\-\d\d)\-([\w\-\d]+)\.md\.adoc" (str file))
title (:title (edn/read-string (slurp (fs/file "posts" (str date "-" slug ".md")))))]
(spit (fs/file "posts" (str slug ".adoc"))
(str "= " title "\nOliver Caldwell\n" date "\n\n" (slurp file)))))
@Olical
Olical / conjure-alpha-usage.md
Last active Oct 7, 2019
Using a super alpha version of Conjure - Clojure socket prepl in Neovim
View conjure-alpha-usage.md

Conjure alpha preview

Neovim Clojure tooling over prepl

This is the legacy Rust implementation that I've replaced with Clojure. Check out the master branch for the main Clojure version. The old source can be found on the legacy-rust-implementation branch.

I've been working on [Conjure][] for a while now and using it day to day at work. It's coming along but I still have a todo list that stretches off the screen. This is mostly "nice to haves", not essential features. I don't want to release it until I've completed my main list and I'm happy with the level of polish.

This gist covers how to set up the current super alpha version (v0.3.0) in your own Neovim so you can give it a go and maybe give me some feedback. Here's the caveats:

@Olical
Olical / fireplace-refresh.vim
Created Apr 18, 2018
Vim bindings for vim-fireplace that act like cider-refresh
View fireplace-refresh.vim
autocmd FileType clojure nnoremap <buffer> <silent> <localleader>rx :Eval (do (bounce.system/stop!) (clojure.tools.namespace.repl/set-refresh-dirs "src/clj" "src/cljc") (clojure.tools.namespace.repl/refresh :after 'bounce.system/start!))<cr>
autocmd FileType clojure nnoremap <buffer> <silent> <localleader>rX :Eval (do (bounce.system/stop!) (clojure.tools.namespace.repl/clear) (clojure.tools.namespace.repl/set-refresh-dirs "src/clj" "src/cljc") (clojure.tools.namespace.repl/refresh-all :after 'bounce.system/start!))<cr>
@Olical
Olical / scheme.vim
Created Apr 15, 2018
Some MIT Scheme bindings intended for Neovim
View scheme.vim
function! scheme#connect()
vnew
let s:repl_term_id = termopen('mit-scheme')
normal! G
endfunction
function! scheme#eval_top_form()
let l:save_clipboard = &clipboard
set clipboard=
let l:save_reg = getreg('s')
@Olical
Olical / cljs_namespace_tools.cljs
Created Mar 6, 2018
ClojureScript (node) to discover namespaces in a directory
View cljs_namespace_tools.cljs
(ns cljs-namespace-tools
(:require [clojure.tools.namespace.parse :as parse]
[cljs.tools.reader.reader-types :as reader-types]
[cljs-node-io.core :as io]
[cljs-node-io.fs :as fs]
[cljs.test :as t]))
(defn path-kind [path]
(cond
(fs/file? path) :file
@Olical
Olical / tree.cljc
Created Sep 16, 2017
Using clojure.spec to parse trees
View tree.cljc
(ns bonsai.tree
(:require #?(:clj [clojure.spec.alpha :as s]
:cljs [cljs.spec.alpha :as s])))
(s/def ::element (s/or :string string?
:element (s/cat :name keyword?
:attrs (s/? (s/map-of keyword? any?))
:children (s/* ::element))))
(s/conform ::element [:p])
@Olical
Olical / lzfn.clj
Created Sep 4, 2017
A function macro that yields the EXACT same function reference if the arguments and body LOOK the same.
View lzfn.clj
;; Wasn't sure on a name, but this'll do.
(def fn-cache (atom {}))
(defmacro lzfn [& forms]
`(let [fn-hash# (hash '~forms)
fn# (get @fn-cache fn-hash#)]
(if fn#
fn#
(let [new-fn# (fn ~@forms)]
@Olical
Olical / rvm.fish
Last active Feb 6, 2017
Changes to rvm.fish so it doesn't make spacemacs error.
View rvm.fish
function rvm --description='Ruby enVironment Manager'
# run RVM and capture the resulting environment
set --local env_file (mktemp -t rvm.fish.XXXXXXXXXX)
bash -c 'source ~/.rvm/scripts/rvm; rvm "$@"; status=$?; env > "$0"; exit $status' $env_file $argv > /dev/null 2>&1
# apply rvm_* and *PATH variables from the captured environment
and grep '^rvm\|^[^=]*PATH\|^GEM_HOME' $env_file | grep -v '_clr=' | sed '/^[^=]*PATH/s/:/" "/g; s/^/set -xg /; s/=/ "/; s/$/" ;/; s/(//; s/)//' | source
# needed under fish >= 2.2.0
and set -xg GEM_PATH (echo $GEM_PATH | sed 's/ /:/g')
@Olical
Olical / fib.rkt
Last active Sep 27, 2016
A fast, recursive, typed fibonacci program written in Racket.
View fib.rkt
#lang typed/racket
(: fib (-> Number Number))
(define (fib n)
(fib-iter 0 1 n))
(: fib-iter (-> Number Number Number Number))
(define (fib-iter a b n)
(if (= n 0) a
(fib-iter b (+ a b) (- n 1))))
You can’t perform that action at this time.