Skip to content

Instantly share code, notes, and snippets.

@exupero
exupero / dnif.go
Created July 30, 2015 17:35
Find a file in an ancestory directory
package main
import (
"flag"
"fmt"
"log"
"os"
"strings"
)
@exupero
exupero / README.md
Last active February 29, 2016 12:57
instruct

instruct

A shell script to give step-by-step instructions. Pipe text into it. It'll be processed as follows:

  • Each line is echoed back to you one at a time.
  • Hit the Enter key to see the next instruction.
  • Lines surrounded by triple backticks are copied to the system clipboard, and the next line of text has the icon next to it.
  • Blank lines are ignored.
  • To insert a blank line, use a triple dash (---).
@exupero
exupero / clipboard.clj
Created September 22, 2017 18:32
Clojure code to interact with the system clipboard
(refer-clojure :exclude '[slurp spit])
(import '[java.awt.datatransfer DataFlavor StringSelection Transferable])
(defn clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn slurp []
(try
(.getTransferData (.getContents (clipboard) nil) (DataFlavor/stringFlavor))
(catch java.lang.NullPointerException e nil)))
@exupero
exupero / cl.cljs
Last active April 26, 2018 18:42
Ad hoc text transformation via Planck
#!/usr/local/bin/planck
(require '[clojure.string :as string])
(require 'cljs.reader)
(require '[planck.core :refer [slurp eval *in* *command-line-args*]])
(def in (slurp *in*))
(defn format-output [x]
(cond
@exupero
exupero / README.md
Last active April 17, 2018 11:28
Putting the Space in Workspace

I use my terminal as an IDE, largely thanks to Tmux. I spin up sessions for the API, the client front-end, and any other codebases I happen to be working in, as well as a session for tracking to do's and ideas.

I launch a session using a script I call zmux. If given a session name, zmux attaches to the session. If given a directory, zmux launches a new session and looks for a .tmuxrc file in the directory that it can source to set up the session, allowing me to easily spin up a workspace and daemon processes for a project. This is especially useful for projects I haven't touched in years.

I created a Tmux binding to switch between sessions on partial session name matches:

unbind t; bind t command-prompt -p "session" "run-shell \"find-tmux-session %%\""
@exupero
exupero / building.clj
Created October 23, 2018 00:55
A state machine example
; Constructing a physical building is, ideally, a linear process, but in reality there can be twists
; and turns and backtracking to previous steps. Here's a state machine that models a simple,
; hypothetical construction process:
(def construction-process
{:concept {:revised-concept :concept
:township-approved :township-permission
:township-rejected :terminated}
:township-permission {:blueprints-delivered :blueprints}
:blueprints {:code-violations :blueprints-in-revision
@exupero
exupero / advent-of-code-2018.clj
Last active December 25, 2018 20:09
Advent of Code 2018
(ns exupero.advent-of-code.2018
(:require [clojure.string :as string]
[clojure.set :refer [intersection rename-keys map-invert]]
[clojure.zip :as zip]
[net.cgrand.xforms :as xf]))
(def parse-int #(Integer/parseInt %))
; Day 1, puzzle 1
(def input-1 (map parse-int (string/split-lines (slurp "./resources/advent-of-code/2018/day-1-input.txt"))))
@exupero
exupero / IntellijNrepl.java
Created April 17, 2019 15:01
Launching a Clojure nREPL from IntelliJ
package squij;
import clojure.lang.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
@exupero
exupero / README.md
Last active January 28, 2022 18:15
Michigan Big Trees
@exupero
exupero / README.md
Last active January 20, 2022 17:00
Michigan county line roads
  • Orange roads use "County Line" names
  • Red roads use hyphenated names
  • Blue roads use portmanteaus