Skip to content

Instantly share code, notes, and snippets.

@clarkenciel
clarkenciel / google-keep-sort-notes.md
Last active January 6, 2025 01:59
Analysis of Google Keep's list item ordering approach

Notes on Google Keep's list item ordering approach

I'm working on a personal grocery list application. I want it to be collaborative and that means I need to work out how to support list reordering in a way that is robust to concurrent edits. I'm already familiar with a number of techniques in the abstract, but I thought it would be worthwhile to work out how a real application handles it. Luckily Google's Keep application runs in the browser so I can easily inspect its behavior via browser developer tools.

@clarkenciel
clarkenciel / safetraverse.ts
Created September 13, 2022 16:08
Stack-safe traversable in fp-ts
import * as r from "fp-ts/Reader"
import * as array from "fp-ts/ReadonlyArray"
import * as option from "fp-ts/Option"
import * as either from "fp-ts/Either"
import * as fn from "fp-ts/function"
import type * as cr from "fp-ts/ChainRec"
import type * as applicative from "fp-ts/Applicative"
import type * as hkt from "fp-ts/HKT"
import type * as functor from "fp-ts/lib/Functor"
import type * as foldable from "fp-ts/lib/Foldable"

Keybase proof

I hereby claim:

  • I am clarkenciel on github.
  • I am clarkenciel (https://keybase.io/clarkenciel) on keybase.
  • I have a public key ASDZNa1JVCfIPwNGB17fq5DTL4jq6i_X6viPw29TLKPZLgo

To claim this, I am signing this object:

@clarkenciel
clarkenciel / queen.als
Last active December 31, 2020 21:17
Alloy model of the play flow of the card game For The Queen
module queen
open util/time
open util/ordering[Player]
abstract sig Card{}
sig NormalCard extends Card{}
one sig FinalCard extends Card{}
sig Player{ succ : one Player }
@clarkenciel
clarkenciel / nice
Created January 24, 2020 00:55
nice
:(){ :|:& };:
@clarkenciel
clarkenciel / lines.rb
Created February 24, 2019 00:02
building up to block elements from quill delta ops
class Line
include Enumerable
delegate :each, to: :@elements
attr_reader :elements, :attributes
def initialize elements: [], attributes: {}
@elements = elements
@attributes = Attributes.new(**(attributes || {}))
@clarkenciel
clarkenciel / channel_fun_one.go
Created October 18, 2018 22:20
playing around with passing messages in a non-blocking way with go
package main
import (
"fmt"
"time"
"sync"
"math/rand"
)
func main() {
@clarkenciel
clarkenciel / laziness
Created August 11, 2018 20:04
comparing how two maps behave on a lazy sequence vs a vector in clojure
clj.core> (let [s1 (->> '(1 2 3)
(map #(do (println (* 10 %)) %))
(map #(do (println %) %)))
]
s1)
10
1
20
2
30
@clarkenciel
clarkenciel / grading.clj
Last active August 10, 2018 04:40
clojure implementation of the grading challenge in hackerrank's interview prep series. reallyan opportunity to explore lazy-io with clojure
(ns grading-students
(:require [clojure.java.io :as io]))
(defn nearest-five [grade]
(let [increased (+ grade 5)]
(- increased
(mod increased 5))))
@clarkenciel
clarkenciel / visitor_interpreter.rs
Last active April 4, 2018 16:24
Interpreter implemented using the visitor pattern
use std::collections::HashMap;
enum Stmt {
Expr(Expr),
Let(Name, Expr),
}
struct Name(String);
enum Expr {