Skip to content

Instantly share code, notes, and snippets.

View jamiepratt's full-sized avatar

James Pratt jamiepratt

View GitHub Profile
@jamiepratt
jamiepratt / wonky-graph.json
Last active November 10, 2022 12:24
wonky-graph.json
{
"description": "Plot showing a 30 day rolling average with raw values in the background.",
"width": 800,
"height": 300,
"data": {
"values": [
{
"amount": 3428.56,
"date": {"month": 11, "year": 2017, "date": 13},
"rolling-mean": 26339.3075
@jamiepratt
jamiepratt / heatmap.clj
Created October 7, 2022 17:58
figuring out how to create a heatmap in vega-lite
(ns heatmap
(:require [nextjournal.clerk :as clerk]
[aerial.hanami.common :as hc]
[aerial.hanami.templates :as ht])
)
(defn heat-map-graph [title data]
(hc/xform ht/heatmap-chart
:TITLE title
:DATA data
We can't make this file beautiful and searchable because it's too large.
"index","a","b","sigma"
"1",154.463029424446,0.92772083455486,4.77531500115427
"2",155.029235091832,0.865009228189656,5.14265740434293
"3",154.749386483007,0.944318746661559,4.95830093670106
"4",154.882538995558,0.913085622253422,5.21154658941009
"5",154.160127355332,0.932373407986481,5.39321059734968
"6",154.720477056833,0.910420398843487,5.04069697859452
"7",155.060590305595,0.819713086692938,5.44063312830036
"8",154.447996257924,0.849465851550294,5.26068685571713
"9",154.698811513831,0.919012523494473,5.14835069594044
(ns coin-toss
(:require [clojure.test :as t]))
(defn expt
"x to the yth power" [x y]
(apply * (repeat y x)))
(defn sum-of-geometric-series
"a(1-r^n )/(1-r)" [a r n]
(ns one-to-nine.core
(:require [clojure.math.combinatorics :as combo]))
(defn all-possible-boards
"What are all the possible combinations of the set of numbers from 1 to x."
[x]
(combo/permutations (range 1 (inc x))))
(defn horiz-vertical-coords
"Index for array for the rows and columns of a board with width * height squares"
(ns euler.p549-divisibility-of-factorials-v4)
(defn to-the-power [factor exp]
(reduce * 1 (repeat exp factor)))
(defn a-prime-factor-for-all-to
([max-n]
(loop [pfs (apply vector-of :int (range 0 (inc max-n)))
n 2]
(if (<= (to-the-power n 2) max-n)
(ns euler.p549-divisibility-of-factorials-v3)
(defn primes
([] (primes (iterate inc 2)))
([s]
(lazy-seq (if (nil? (first s))
nil
(cons (first s)
(primes
@jamiepratt
jamiepratt / blockly.xml
Created March 12, 2021 16:45
New Project
Close
@jamiepratt
jamiepratt / Playground.hs
Created February 27, 2021 19:25
Plutus Playground Smart Contract
import qualified Data.Text as T
import Language.Plutus.Contract hiding (when)
import Language.PlutusTx.Prelude
import Playground.Contract
-- | A 'Contract' that logs a message.
hello :: Contract BlockchainActions T.Text ()
hello = logInfo @String "Hello, world"
endpoints :: Contract BlockchainActions T.Text ()
module Prettify
(
-- * Constructors
Doc
-- * Basic combinators
, (<>)
, empty
, char
, text
, line