Skip to content

Instantly share code, notes, and snippets.

@antonycourtney
antonycourtney / DiamondExample.md
Last active April 30, 2022 19:10
A real world example of recombinant / diamond wiring and feedback with RxJS

A realistic RxJS app with diamond wiring

Consider the following user interface (inspired by Strava) for looking at time-series charts of network data:

esnet-estes-charts

Notes on this interface and my Rx implementation of it:

  • Each chart (stacked vertically) charts a different metric (latency, packet loss and throughput) but over the same time period.
  • As the user moves the mouse left and right on any chart, the vertical line (called the tracker) moves to track the mouse position on all charts. The number displayed in the gray box on the right is the value underneath the tracker for that metric.
@antonycourtney
antonycourtney / FunPix.hs
Created March 4, 2016 23:47
Layout thought of as an attribute grammar, encoded in Haskell
--
-- Some experiments with a Picture type based on an attribute-grammar
-- model of Layout
module FunPic where
import Haven
-- A type for representing the dimensions of a rectangle, as (width,height)
type Dimension = (Double,Double)
@antonycourtney
antonycourtney / interp.lhs
Last active May 5, 2016 19:25
My own notes and exercises written while reading Wadler's wonderful "Monads for Functional Programming" in 1998
A really simple interpreter to use while learning about monads. Based on
the paper "Monads for Functional Programming" by Phil Wadler.
the type of terms:
> data Term = Con Int
> | Div Term Term
> deriving Show
@antonycourtney
antonycourtney / Timer.js
Created January 4, 2017 18:11
Example of maintaining Timer state for use in React
/* @flow */
import * as Immutable from 'immutable'
/**
* A timer object for use in OneRef-based immutable state
*
*/
export type TimerUpdater = (f: (ts: Timer) => Timer) => void
@antonycourtney
antonycourtney / flow-lambda-bug.js
Created March 31, 2017 02:10
Flow data flow analysis loses info under a lambda
/* @flow */
/* Paste this into https://flow.org/try/ to see the bug: */
const f = (lut: ?{[key: string]: number}): number => {
// This correctly notices that we're doing a null check on lut:
const testKey = 'fizz'
const y = (lut != null) ? lut[testKey] : 0
@antonycourtney
antonycourtney / fruit-reflections-2008.md
Last active November 6, 2017 05:41
Reflections on why Fruit (A prototype Functional Reactive UI Toolkit for Haskell) never took off (2008)
Received: by 10.140.161.21 with HTTP; Fri, 22 Feb 2008 06:35:48 -0800 (PST)
Message-ID: <3be64c030802220635i3380e50fh70bf62e0bdc6d5a0@mail.gmail.com>
Date: Fri, 22 Feb 2008 09:35:48 -0500
From: "Antony Courtney" <antony.courtney@gmail.com>
To: "Conal Elliott" <conal@conal.net>
Subject: Re: Fruit
Cc: Yampa-Users <yampa-users@cs.yale.edu>
In-Reply-To: <ea8ae9fb0802211906t232938c5wded0a56b35ceaa2d@mail.gmail.com>
MIME-Version: 1.0
@antonycourtney
antonycourtney / goodreads-cleanup.sql
Last active January 15, 2023 23:01
Parquet cleaning example in DuckDb SQL
-- This should all work with the DuckDb shell CLI, available from https://duckdb.org/docs/installation/index
-- (Select the CLI tab)
-- first create a view on the Parquet file:
CREATE VIEW books AS SELECT * from './goodreads_books.parquet';
-- take a look at the schema:
PRAGMA table_info(books);
-- Fix up one of the columns (book_id), converting it from VARCHAR to INTEGER (int32):