Skip to content

Instantly share code, notes, and snippets.

Avatar

Ethan Miller ezmiller

View GitHub Profile
@ezmiller
ezmiller / scicloj-workshop-template.md
Last active March 15, 2022 02:09
Scicloj Workshop Template
View scicloj-workshop-template.md

Work In Progress

Scicloj Workshop: [Add workshop title]

[Add workshop description]

Workshop Length & Structure

[Describe number of workshop meetings, time and length]

View sales-data-sample.json
[
{
"Promo": 1,
"Sales": 5263
},
{
"Promo": 1,
"Sales": 5020
},
{
@ezmiller
ezmiller / hours-plot-data.csv
Created June 10, 2021 02:17
#scicloj-phase-transitiion hours data - 2021-06-09
View hours-plot-data.csv
day hour overlaps
monday 0 1
monday 1 1
monday 2 2
monday 3 3
monday 4 3
monday 5 3
monday 6 2
monday 7 1
monday 8 0
@ezmiller
ezmiller / gist:e642960d4653f0c8a54ca15d2fd5e041
Created December 29, 2020 18:50
Clojure lazy sequence of days from 1970-01-01 using java.time
View gist:e642960d4653f0c8a54ca15d2fd5e041
;; Creates a lazy sequence of days from 1970-01-01
(defn days-from-epoch
([] (days-from-epoch (java.time.LocalDate/parse "1970-01-01")))
([local-date]
(prn local-date)
(lazy-seq (cons local-date (days-from-epoch (.plusDays local-date 1))))))
(take 2 (days-from-epoch))
;; => (#time/date "1970-01-01" #time/date "1970-01-02")
@ezmiller
ezmiller / checkout-branch-on-fork
Created October 2, 2019 10:24
Checking out a branch from a fork
View checkout-branch-on-fork
# See here: https://github.community/t5/How-to-use-Git-and-GitHub/Checkout-a-branch-from-a-fork/td-p/77
git ls-remote --refs origin -- will list refs for remote `origin`, some will look like `refs/pull/<some-num>/head`
git fetch origin pull/123/head:pr/123 && git checkout pr/123 # fetch and checkout PR #123, eg.
View use-clj-plot.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ezmiller
ezmiller / factorial.clj
Created October 2, 2018 14:21
Recursive Factorial
View factorial.clj
(defn factorial [n]
(if (= n 1)
1
(* n (factorial (- n 1)))))
View 2016-kings-county-pres-primary-35th-color.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ezmiller
ezmiller / Datomic News Updates
Created March 12, 2017 17:25 — forked from k1m190r/Datomic News Updates
Datomic update examples against a social news database
View Datomic News Updates
;; Datomic example code
;; demonstrates various update scenarios, using a news database
;; that contains stories, users, and upvotes
;; grab an in memory database
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://foo")
(d/create-database uri)
(def conn (d/connect uri))
@ezmiller
ezmiller / wrap_strings.R
Created August 22, 2016 05:54
R function for wrapping long strings
View wrap_strings.R
## Function to wrap long strings
# Source: http://stackoverflow.com/a/7367534/496488
wrap_strings <- function(vector_of_strings,width) {
as.character(
sapply(vector_of_strings, FUN=function(x) {
paste(strwrap(x, width=width), collapse="\n")
})
)
}