Skip to content

Instantly share code, notes, and snippets.

Avatar

Jack Rusher jackrusher

View GitHub Profile
View reload-chrome.sh
#!/usr/bin/osascript
tell application "Chrome" to tell the active tab of its first window
reload
end tell
@jackrusher
jackrusher / deploy.sh
Created Jan 17, 2022
Writing and deploying Google Cloud Functions in Clojure using NBB
View deploy.sh
# command line to deploy the project
gcloud functions deploy hello --runtime nodejs14 --trigger-http
View truchet-os.asm
;; Boot to PRINT10
;;
;; Use nasm to assemble the code to a binary:
;;
;; $ nasm -f bin -o boot.bin boot.nasm
;;
;; Use dd to make an empty floppy disk image:
;;
;; $ dd if=/dev/zero of=boot.flp ibs=1k count=1440
;;
@jackrusher
jackrusher / seq-primer.clj
Created Jun 1, 2021
Condensed visual tutorial in #Bauhaus style for a subset of the #Clojure seq API (inspired by similar JS tweets)
View seq-primer.clj
(def ■ '■)
(def ▲ '▲)
(def ● '●)
(first [● ■ ▲]) ;
(second [● ■ ▲]) ;
(nth [● ■ ▲] 2) ;
(rest [● ■ ▲]) ; (■ ▲)
(last [● ■ ▲]) ;
(butlast [● ■ ▲]) ; (● ■)
View twitter-gifs.md

Twitter abuses all media file uploads, each type in its own way. If we want to upload a good looking animation loop from some low-color, high-detail generative art, we have to game their system's mechanisms.

  • don't upload a video file, they will re-encode it into absolute 💩

  • create a GIF, which they will auto-convert into a video file 😱

  • The frames of the GIF will be resized to an even-sized width using an extremely naive algorithm. Your GIF should be an even size (1000, 2000,

View AAA-README.md

Meld

A minimal example of creating a (mostly) working FUSE filesystem using Clojure. NOTE: I have only tested this with OSX, and it assumes you have already installed libfuse.

Trying it out

Create an empty directory at /tmp/meld to serve as your mount point, put these files in a directory called meld, then:

@jackrusher
jackrusher / json->edn.el
Created Apr 16, 2020
Convert the current region in emacs from JSON to EDN using Bork's Jet.
View json->edn.el
;; Uses https://github.com/borkdude/jet
;; On OSX, install jet with:
;; brew install borkdude/brew/jet
;; I invoke this with M-x, you might want to bind it to a key
(defun json->edn ()
(interactive)
(shell-command-on-region (region-beginning)
View extract-tables.clj
(ns appliedsciencestudio.covid19-clj-viz.repl
(:require [clojure.string :as string]
[hickory.core :as hick]
[hickory.select :as s]))
;;;; Scraping data
(def wiki-page
"We want this data, but it's only published as HTML."
(slurp "https://en.wikipedia.org/wiki/List_of_countries_by_hospital_beds"))
View scrape-worldometer.clj
(ns appliedsciencestudio.covid19-clj-viz.repl
(:require [clojure.string :as string]
[hickory.core :as hick]
[hickory.select :as s]))
;;;; Scraping data
(def worldometers-page
"We want this data, but it's only published as HTML."
(-> (slurp "https://www.worldometers.info/coronavirus/")
hick/parse
@jackrusher
jackrusher / emacs-related.sh
Created Mar 4, 2020
A few shell things to make working with emacs nicer (OSX focus)...
View emacs-related.sh