Skip to content

Instantly share code, notes, and snippets.

@exupero
exupero / stack-math.clj
Last active December 31, 2023 16:29
Stack math evaluator
#!/usr/bin/env bb
(ns stack-math
(:require [clojure.string :as str]
[clojure.core.match :refer [match]]
[clojure.tools.cli :as cli]))
(defn parse-stack [s]
(read-string (format "[%s]" s)))
#!/usr/bin/env bb
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {org.clojars.askonomm/ruuter {:mvn/version "1.3.2"}}})
(require '[clojure.java.browse :as browse]
'[clojure.string :as str]
'[cheshire.core :as json]
'[org.httpkit.server :as srv]
'[ruuter.core :as ruuter]
@exupero
exupero / serve.clj
Created January 30, 2023 16:11
Babashka HTTP server that watches files
#!/usr/bin/env bb
(ns server
(:require [clojure.string :as string]
[clojure.java.browse :as browse]
[clojure.tools.cli :refer [parse-opts]]
[babashka.fs :as fs]
[org.httpkit.server :as server])
(:import [java.net URLDecoder]
[java.time Instant]))
@exupero
exupero / README.md
Last active February 6, 2024 22:24
Mid-oceanic ridge

Traced from this image of crustal age and assuming an equirectangular projection.

I've imagined a connection between where the ridge disappears under Alaska and where it emerges from eastern Siberia.

If you know where I can find proper geographical coordinates for the mid-oceanic ridge, please leave a comment.

@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
@exupero
exupero / README.md
Last active January 28, 2022 18:15
Michigan Big Trees
@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 / 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 / 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 / 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 %%\""