This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/lumo | |
(ns app.core | |
"This application watches the a directory <DIR> for screen shots | |
and applies an OCR to them (`tesseract`). The resulting text file is | |
saved to a directory called '<DIR>/OCR Screen Shots`.") | |
(def fs | |
(js/require "fs")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn longest-prefix-at | |
[s i] | |
(let [max-k (. s length)] | |
(or (last (for [j (range 1 max-k) | |
:let [k (+ i j)] | |
:when (<= k max-k) | |
:let [s1 (subs s 0 j) | |
s2 (subs s i k)] | |
:while (= s1 s2)] | |
s2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn swap | |
"Swap the elements at positions `i` and `j` in `v`." | |
{:private true} | |
[v i j] | |
(-> v | |
(assoc i (get v j)) | |
(assoc j (get v i)))) | |
;; SEE: https://en.wikipedia.org/wiki/Heap%27s_algorithm | |
(defn permutations [coll] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def with_repl_friendly_inspect(&block) | |
x = block.call | |
case x | |
# We don't want to and sometimes can't override the #inspect method | |
# of these classes of values. | |
when Array, | |
Class, | |
FalseClass, | |
Hash, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns conform-case | |
(:require [clojure.spec :as spec])) | |
(defn build-clause-form | |
{:private true} | |
[expression-form clause else-form] | |
(let [[spec binding-form & body] clause] | |
`(let [conform-value# (spec/conform ~spec ~expression-form)] | |
(if (= conform-value# ::spec/invalid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun intero-scratch-send-paragraph () | |
(interactive) | |
(let* ((source-code-start (save-excursion | |
(backward-paragraph) | |
(point))) | |
(source-code-end (save-excursion | |
(forward-paragraph) | |
(point))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns strum.core | |
(:refer-clojure :exclude [defn]) | |
(:require | |
[clojure.spec :as spec] | |
[clojure.spec.test :as spec.test])) | |
;; --------------------------------------------------------------------- | |
;; Prelude | |
;; HACK: Currently, as of Clojure 1.9.0-alpha14, there is a bug with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns machines.cek | |
(:require | |
[clojure.core.match :as match] | |
[clojure.spec :as spec])) | |
;; e ∈ Exp ::= x | (e e) | (λ (x) e) | |
;; x ∈ Var | |
;; ς ∈ Σ = Exp × Env × Kont | |
;; v ∈ Val ::= (λ (x) e) | |
;; ρ ∈ Env = Var →_fin Val × Env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns state-box) | |
(defprotocol IGetState | |
(-get-state [state key])) | |
(defprotocol IPutState | |
(-put-state [state key value])) | |
(deftype ImmutableBox [get-state put-state state] | |
IGetState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::BufRead; | |
use std::io::BufReader; | |
use std::io::ErrorKind; | |
use std::io::Write; | |
use std::net::TcpListener; | |
use std::net::TcpStream; | |
use std::thread; | |
use std::time::Duration; | |
fn handle_tcp_stream(mut tcp_stream: TcpStream) { |