Skip to content

Instantly share code, notes, and snippets.

@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):
@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 / 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 / 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 / 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 / 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 / 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 / Example1.elm
Last active November 8, 2015 06:00
Animaxe Example 1 in Elm
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import List exposing (..)
import Signal exposing (..)
import Time exposing (..)
import Array
-- a square of the given width and color:
square : Float -> Color -> Form
@antonycourtney
antonycourtney / ChatAppState.js
Last active October 19, 2015 03:46
oneref-chat application state
/**
*
* ChatAppState.js - atate of Chat application as an Immutable record
*
* Our application state consists of a collection of message threads
* and a current thread (identified by its thread ID)
*
* Each thread id maps to a Thread (a collection of Message)
*/
const emptyThread = new Thread();
@antonycourtney
antonycourtney / invokeLater.js
Last active October 19, 2015 03:11
invokeLater for oneref
function invokeLater(f) {
window.setTimeout(f, 0);
}