Skip to content

Instantly share code, notes, and snippets.

View kyptin's full-sized avatar

Jeff Terrell kyptin

View GitHub Profile
@kyptin
kyptin / deploy-current-commit.sh
Created June 17, 2019 17:29
Deploy current commit to Datomic Ions
#!/bin/bash
# This automates the process of using Datomic Ions to push, deploy, and wait for
# the deployment to finish. It works as of com.datomic/ion.dev version 0.9.229.
# For more info, see https://docs.datomic.com/cloud/ions/ions.html
set -euxo pipefail
status_cmd=$(clj -A:dev -m datomic.ion.dev '{:op :push}' 2>&1 | \
grep -v ^Downloading | \
@kyptin
kyptin / before.js
Created October 21, 2019 16:40
Effects refactoring example (UNC COMP 523)
// Goal: assign students to seats
// Usage: node before.js
// Context: UNC COMP 523 (https://comp523.cs.unc.edu)
// Exercise: refactor to manage effects better
const makePref = ([pid, section, isVip]) =>
({pid, section, isVip, isAssigned: false})
const makePrefs = (rows) => rows.map(makePref)
@kyptin
kyptin / behaviors_quiz.clj
Created February 12, 2020 15:24
Code for an in-class quiz (COMP 590/spring 2020) for listing behaviors of a function
;; To write tests for this function, what behaviors would you list?
(defn summation
([xs] (summation identity xs))
([f xs] (reduce + 0 (map f xs))))
@kyptin
kyptin / isolated_behaviors_quiz.clj
Created February 17, 2020 15:20
Code for an in-class quiz (COMP 590/spring 2020) for listing behaviors of a function assuming isolated tests
;; To write tests for this function, what behaviors would you list?
(defn pascal-row
"Return a seq of the numbers in the n-th row of Pascal's triangle (where n=0 is
the first row)."
[n]
(for [i (range (inc n))]
(combinations n i)))
@kyptin
kyptin / commits.clj
Created March 2, 2020 15:58
Fetch commit author frequences from the GitHub API (COMP 590 in-class exercise)
(ns commits
(:require [clj-http.client :as http]
[clj-json.core :as json]
[clojure.pprint :refer [pprint]]))
(def api-url "https://api.github.com/repos/clojure/clojure/commits")
(defn get-committers-from-page [n]
(some->> (http/get api-url {:query-params {"per_page" 100, "page" n}})
:body
@kyptin
kyptin / reload-safari-tab.sh
Last active November 3, 2022 13:47
reload-safari-tab - use osascript to reload a safari tab by url substring - composable with entr for auto-reloading
#!/bin/bash
set -euo pipefail
usage() {
echo "$(basename "$0") - Reload any Safari tabs that contain the given string."
echo "Usage:"
echo " $(basename "$0") STRING"
echo " fd <opts> | entr reload-safari-tab STRING"
}