Skip to content

Instantly share code, notes, and snippets.

View declann's full-sized avatar
👋

Declan Naughton declann

👋
View GitHub Profile
@declann
declann / index.html
Last active March 20, 2021 16:47
test
hellofff
// at time 0 (when t_in=0) values for x and dy are 0, while value for y is 50 (values hardcoded below).
// the floor is at y=190 so the ball will start falling until it reaches 190, and then bounce.
// dy calculates the change to y in each time step (except where the "floor rule" bites).
// dy is 3 at t_in=1 and is influenced by a dampener input
/////////// model ///////////
// explicit inputs (by convention):
export const t = () => t_in;
export const dx = () => dx_in;
**Shell of DN blog for [calculang](https://github.com/calculang/calculang)**
Under motivation I list:
- separation of concerns
- unity
- transparency
- democratisation of numbers
I need to elaborate on these, e.g. in relation to some examples.
@declann
declann / bounce.js
Last active November 18, 2021 12:44
brets bounce
p5(sketch => {
sketch.setup = function () {
sketch.createCanvas(width, 200);
};
var x = 0, y = 50, dy = 0;
sketch.draw = function () {
if (x > 600) { x = 0; y = 50; dy = 0; }
sketch.background("#001b42");
x += dx_in;
@declann
declann / spec.json
Created November 23, 2021 14:31
Vega-Lite spec from Tue Nov 23 2021
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"facet": {"row": {"field": "function", "type": "ordinal"}},
"data": {
"values":[{"t_in":0,"dx_in":-3,"function":"x","value":97},{"t_in":0,"dx_in":0,"function":"x","value":100},{"t_in":0,"dx_in":3,"function":"x","value":103},{"t_in":1,"dx_in":-3,"function":"x","value":94},{"t_in":1,"dx_in":0,"function":"x","value":100},{"t_in":1,"dx_in":3,"function":"x","value":106},{"t_in":2,"dx_in":-3,"function":"x","value":91},{"t_in":2,"dx_in":0,"function":"x","value":100},{"t_in":2,"dx_in":3,"function":"x","value":109},{"t_in":3,"dx_in":-3,"function":"x","value":88},{"t_in":3,"dx_in":0,"function":"x","value":100},{"t_in":3,"dx_in":3,"function":"x","value":112},{"t_in":4,"dx_in":-3,"function":"x","value":85},{"t_in":4,"dx_in":0,"function":"x","value":100},{"t_in":4,"dx_in":3,"function":"x","value":115},{"t_in":5,"dx_in":-3,"function":"x","value":82},{"t_in":5,"dx_in":0,"function":"x","value":100},{"t_in":5,"dx_in":3,"function":"x","value":118},{"dx_i
@declann
declann / spec.json
Created November 29, 2021 00:35
failing elk Vega-Lite spec from Mon Nov 29 2021
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "description TODO",
"data": {
"values": [
{"t_in": 0, "dx_in": -3, "function": "x", "value": 97},
{"t_in": 0, "dx_in": 0, "function": "x", "value": 100},
{"t_in": 0, "dx_in": 3, "function": "x", "value": 103},
{"t_in": 1, "dx_in": -3, "function": "x", "value": 94},
{"t_in": 1, "dx_in": 0, "function": "x", "value": 100},
[
{
"budgetYear": 0,
"forecastYear": -1,
"value": 100
},
{
"budgetYear": 0,
"forecastYear": 0,
"value": 104.5
@declann
declann / spec.json
Last active December 7, 2021 16:59
subs rec data -> budgets vega example
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A recreation of a New York Times chart showing U.S. budget forecasts versus reality.",
"width": 700,
"height": 400,
"padding": 5,
"background": "#edf1f7",
"config": {
"axisBand": {
[
{
"detail": -1,
"type": "Actual",
"function": "subs",
"year": -1,
"value": 100
},
{
"detail": -1,
@declann
declann / spec.json
Created December 7, 2021 18:43
projections and discontinuities (actuals)
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "https://gist.githubusercontent.com/declann/a1ee5de2ab49980f94f58ef9af20ca96/raw/52d4e16584e4abfab765e37495392eb7e3b87b18/gistfile1.txt"},
"mark": {"type": "line", "point": true},
"encoding": {
"x": {"field": "year", "type": "ordinal"},
"y": {"field": "value", "type": "quantitative", "scale": {"zero": false}},
"detail": {"field": "detail", "type": "ordinal"}
}
}