Skip to content

Instantly share code, notes, and snippets.

View jackrusher's full-sized avatar

Jack Rusher jackrusher

View GitHub Profile
@jackrusher
jackrusher / json->edn.el
Created April 16, 2020 13:26
Convert the current region in emacs from JSON to EDN using Bork's Jet.
;; 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)
(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"))
(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 March 4, 2020 10:57
A few shell things to make working with emacs nicer (OSX focus)...
;; Where are all the -ow -itz place names in Germany? (Limit to 10 for printability)
(query
'[:select *
:where [[?ort (wdt :instance-of) / (wdt :subclass-of) * (entity "human settlement")
_ (wdt :country) (entity "Germany")
_ rdfs:label ?name
_ (wdt :coordinate-location) ?wo]
:filter ((lang ?name) = "de")
:filter ((regex ?name "(ow|itz)$"))]
:limit 10])
@jackrusher
jackrusher / negative-harmony.clj
Created June 25, 2019 13:40
Some example code for calculating triad transformations using Ernst Levy's concept of Negative Harmony, as recently popularized by Jacob Collier.
(def the-notes
(cycle [:c :db :d :eb :e :f :gb :g :ab :a :bb :b]))
(def key-offset
(zipmap (take 12 the-notes) (range)))
(defn triads [the-key]
(let [offset (key-offset the-key)
scale (cycle [0 2 4 5 7 9 11])]
(map
@jackrusher
jackrusher / gcloud-tramp.el
Created June 19, 2019 13:58
Tramping into GCloud instances from within emacs
;; make sure you've set your default project with:
;; gcloud config set project <project-name>
(require 'tramp)
(add-to-list 'tramp-methods
'("gcssh"
(tramp-login-program "gcloud compute ssh")
(tramp-login-args (("%h")))
(tramp-async-args (("-q")))
(tramp-remote-shell "/bin/sh")
(ns planetoid
(:require [chia.util.js-interop :as j]
["three" :as three]
["bezier-easing" :as BezierEasing]))
(defonce renderer
(doto (three/WebGLRenderer. (clj->js :antialias true))
(.setPixelRatio (.-devicePixelRatio js/window))
(.setSize (.-innerWidth js/window) (.-innerHeight js/window))
(.setClearColor "#000000")
@jackrusher
jackrusher / hotkey.el
Created February 27, 2019 11:15
I like to have an emacs keybinding to refresh the frontmost Chrome window.
(global-set-key (kbd "<F12>")
(lambda ()
(shell-command "refresh-chrome")))
(ns drei
(:require [chia.util.js-interop :as j]
["three" :as three]
["bezier-easing" :as BezierEasing]
[colours :refer [palettes]])) ; from Google's art palettes project
(defonce renderer
(doto (three/WebGLRenderer. (clj->js :antialias true))
(.setPixelRatio (.-devicePixelRatio js/window))
(.setSize (.-innerWidth js/window) (.-innerHeight js/window))