Skip to content

Instantly share code, notes, and snippets.

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps

  1. what is a parser?
  2. and.. what is a parser combinator?

So first question: What is parser?

@rusev
rusev / untilDestroyed.ts
Created May 17, 2019 14:22 — forked from ThomasBurleson/untilDestroyed.ts
Using untilViewDestroyed to link component ngOnDestroy to observable unsubscribe.
/**
* When manually subscribing to an observable in a view component, developers are traditionally required
* to unsubscribe during ngOnDestroy. This utility method auto-configures and manages that relationship
* by watching the DOM with a MutationObserver and internally using the takeUntil RxJS operator.
*
* Angular 7 has stricter enforcements and throws errors with monkey-patching of view component life-cycle methods.
* Here is an updated version that uses MutationObserver to accomplish the same goal.
*
* @code
*
@rusev
rusev / appEntryPoint.js
Created September 9, 2019 16:13 — forked from markerikson/appEntryPoint.js
Webpack React/Redux Hot Module Reloading (HMR) example
import React from "react";
import ReactDOM from "react-dom";
import configureStore from "./store/configureStore";
const store = configureStore();
const rootEl = document.getElementById("root");
@rusev
rusev / server-preload.js
Created June 27, 2023 09:45 — forked from justjake/server-preload.js
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See https://jake.tl/notes/2021-04-04-nextjs-preload-hack
// @ts-check
"use strict"
/**
* Set up datadog tracing. This should be called first, so Datadog can hook
* all the other dependencies like `http`.
*/
function setUpDatadogTracing() {
const { tracer: Tracer } = require('dd-trace')
const tracer = Tracer.init({
@rusev
rusev / cell-tests.rs
Created November 17, 2023 12:51 — forked from jonhoo/cell-tests.rs
cell-refcell-rc
// these aren't _quite_ functional tests,
// and should all be compile_fail,
// but may be illustrative
#[test]
fn concurrent_set() {
use std::sync::Arc;
let x = Arc::new(Cell::new(42));
let x1 = Arc::clone(&x);
std::thread::spawn(move || {
@rusev
rusev / playgrounds.txt
Created January 2, 2024 12:57 — forked from Andarist/playgrounds.txt
TS Congress - Reverse Mapped Types TS playgrounds
// identity mapped type
https://www.typescriptlang.org/play?#code/PTAEEsDsAcFcBcBQ8Ce0CmoDyAjAVqALygDeioFoAZgPY0BcoAzvAE5QDmANOZTgIatGkWAFsc6VogC+iRCGqxIAY3jgakZGkwBJACbpIa1AB4AKgD4ipXhQDaAaQiRQAa3QoaVUGYC6jM0dfGTkFZX4AGwitDFAAZX5RTGJ9Q2MUE1w8CyA
// promisify mapped type
https://www.typescriptlang.org/play?#code/C4TwDgpgBA8gRgKygXigbygMwPbYFxQDOwATgJYB2A5gDRRwCGJBFArgLZwQlQC+AUP1CQoABRLZ2ZQmUwgAPABUAfCnT8omqAG0A0lEpQA1hBDZMURQF0CACgCUKVeMnSISvVeX8BQ8NBcpGUwyCAATNUDpWQV4BG9+MIgAYwAbJmhk7ApiKBIwZIIo4NCwwSyc4CxWYFYSaFR85IA6RhIHQUwauohm4AALCApbWwA3BlTHZFU0DS1x1J97IA
// SatisfyName, get access to ur own key in the callback
https://www.typescriptlang.org/play?#code/PTAEDMFcDsGMBcCWB7aAoeBPADgU1AMoCGSAzuJgHJEC2uAPACoB8oAvKAN5qigDaAaVCJooANa5MycKEYBdAFygAFNFq4lAgJTtWAN2SIAJgG40AXzNojuWABsiAJ3xQ4SVKFIlE5TAHkAIwArW3hqOiZmZWRgpWIyCnCGFi0lA2MrLwT-YNCk5U5QEFBkSHhsMp5QIiVVdR02Vm4q3jU6M15zABoqgNq23AamltARgY7QbostEyA
// provideValue, just pairs of data and callbacks that get *their* data as an argument
https://www.typescript
@rusev
rusev / hello.c
Created May 24, 2024 09:37 — forked from nickav/hello.c
WASM from Scratch
// Types
#define NULL 0
typedef unsigned char u8;
typedef unsigned int u32;
typedef signed int i32;
typedef signed long long i64;
typedef double f64;
// Imports