Skip to content

Instantly share code, notes, and snippets.

View tbergman's full-sized avatar

tbergman

View GitHub Profile
@tbergman
tbergman / audio-to-midi.md
Created June 14, 2024 14:38 — forked from 0xdevalias/audio-to-midi.md
Some notes on Automated Audio Transcription (AAT) / Automated Music Transcription (AMT) (aka: converting audio to midi)

Automated Audio Transcription (AAT) / Automated Music Transcription (AMT) (aka: converting audio to midi)

Some notes on Automated Audio Transcription (AAT) / Automated Music Transcription (AMT) (aka: converting audio to midi)

Table of Contents

@tbergman
tbergman / react-scheduler.md
Created October 3, 2021 17:45 — forked from Jessidhia/react-scheduler.md
Implementation notes on react's scheduling model as of (shortly before) 16.8.0

Implementation notes on react's scheduling model as of (shortly before) 16.8.0

While the public API intended for users to use is the scheduler package, the reconciler currently does not use scheduler's priority classes internally.

ReactFiberScheduler has its own internal "mini-scheduler" that uses the scheduler package indirectly for its deadline-capable scheduleCallback.

This is kind of a documentation of implementation details that I suppose will be gone by the end of the year, but what can you do.

Fundamentals: why state machines?

States. The final frontier. These are the voyages of an enterprising developer. Her eternal mission: to explore strange new techniques, to seek out better ways to engineer for mental models and new design patterns. To boldly go where a few awesome devs have gone before.

So you’ve found our poignant guide to SCXML and surely you’re wondering “Why should I want to go out of my way to use formal state machines?” or something like that. Hopefully this introduction addresses that kind of question.

An example: Nancy’s RPG

The problem

@tbergman
tbergman / editableTextMachine.ts
Created September 28, 2020 17:37 — forked from cevr/editableTextMachine.ts
xstate fp utils POC
import * as x from './xstate-fp';
export enum EditableTextState {
idle = 'idle',
editing = 'editing',
}
export enum EditableTextEvent {
mouseenter = 'mouseenter',
mouseleave = 'mouseleave',
@tbergman
tbergman / statechart-xstate.md
Created September 10, 2020 14:37 — forked from coodoo/statechart-xstate.md
Extensive research of statecharts with a focus on front-end development.

The case for statechart and xstate -- why it matters and how we can benefit from it

Bottom line up front

  • redux is a global data management tool, not a proper state management tool, hence causing a lot of troubles

  • statecharts is an extension to Finite State Machine (FSM) which provides explicit and safe state management capabilities, perfectly fit for front-end development

  • statecharts had been used intensivelly in all industries (be it embedded systems, hardware, electronics, aeronautics, automotive, game development and more), it's us front-end developers late to the party

@tbergman
tbergman / statechart-xstate.md
Created September 10, 2020 14:37 — forked from coodoo/statechart-xstate.md
Extensive research of statecharts with a focus on front-end development.

The case for statechart and xstate -- why it matters and how we can benefit from it

Bottom line up front

  • redux is a global data management tool, not a proper state management tool, hence causing a lot of troubles

  • statecharts is an extension to Finite State Machine (FSM) which provides explicit and safe state management capabilities, perfectly fit for front-end development

  • statecharts had been used intensivelly in all industries (be it embedded systems, hardware, electronics, aeronautics, automotive, game development and more), it's us front-end developers late to the party

@tbergman
tbergman / machine.js
Last active November 1, 2019 19:27
Generated by XState Viz: https://xstate.js.org/viz
const SPLASHSCREEN_SHOW_TIME = 1000;
const AppStates = {
Splashscreen: "Splashscreen",
Menu: "Menu",
Playing: "Playing",
Gameover: "Gameover"
}
const AppEventType = {
@tbergman
tbergman / machine.js
Created October 8, 2019 11:35 — forked from valscion/machine.js
Generated by XState Viz: https://xstate.js.org/viz
const handleRequestSuccess = assign({
results: (_ctx, event) => event.results
});
const handleHistoryPopState = assign({
results: (_ctx, event) => event.results
});
const searchFSM = Machine({
id: 'search',
@tbergman
tbergman / clojure_is_for_type_b_personalities.md
Created October 17, 2016 16:05
Clojure is for type B personalities

The other day, I was wondering why Clojure fits my brain so well. I think I was relaxing on my old couch, drinking cheap beer, eating a gas station pastry, and drawing doodles on a stack of overdue bills I forgot to pay. Little did I realize, these things are all connected.

I have a hypothesis that people choose programming languages based on their personality. For the purposes of this write-up, I’ll use the well-known distinction between type A and type B people. This may be pop psychology stuff, but it’s convenient for my point so in the spirit of American politics I will treat it as fact.

Type A vs Type B

Type A people are very organized, competitive, punctual, and like to plan ahead. When I was a kid, these were the ones who had perfect grades, competed in track or swimming, and on top of that they were nice people so I couldn't even hate the fuckers. Type B people, on the other hand, are laid back and like to do things spontaneously. Like The Dude from The Big Lebowski, they are comfortable with