Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Phillips matthewp

View GitHub Profile
View pnpm-where
#!/bin/bash
bin_name=$1
bin_path="node_modules/.bin/$bin_name"
bin_dir=$(dirname $bin_path)
if [ ! -f "$bin_path" ]; then
echo "$bin_path does not exists"
exit 1
fi
View 00explainer.md
@matthewp
matthewp / parser.md
Last active Oct 29, 2021
Binding DSL
View parser.md

Memory layout

1 imported page

[source 32KiB, internal 16KiB, external 16KiB]

Internal

@matthewp
matthewp / readme.md
Created Sep 17, 2021
streaming tests
View readme.md
deno run --allow-net --unstable server.js
@matthewp
matthewp / r.ts
Created Sep 1, 2021
url-relative
View r.ts
import { resolve } from 'https://deno.land/std@0.105.0/path/posix.ts';
const CHAR_FORWARD_SLASH = 47;
/**
* Return the relative path from `from` to `to` based on current working directory.
* @param from path in current working directory
* @param to path in current working directory
*/
export function relative(origFrom: string, origTo: string): string {
@matthewp
matthewp / to-byte-source.js
Last active Aug 5, 2021
Convert a file to its byte source equivalent
View to-byte-source.js
const fileName = Deno.args[0];
if(!fileName) {
console.error('No file provided.');
Deno.exit(1);
}
let file = await Deno.open(fileName);
let encoder = new TextEncoder();
@matthewp
matthewp / basic.js
Last active Jun 24, 2021
Event observable
View basic.js
function listen(fn) {
const gen = fn();
function listener(ev) {
let { done } = gen.next(ev);
if(done) {
this.removeEventListener(ev.type, listener);
gen.return();
}
@matthewp
matthewp / notes.ts
Created Jun 18, 2021
lucy typescript notes
View notes.ts
import { EventObject, Guard, InvokeCreator, StateMachine } from 'xstate'
type EventNames = 'GO_BACK' | 'GO_FORWARD' | 'GO_SIDEWAYS';
type KnownContextKeys = 'user';
type LucyKnownContext<Keys extends string> = Record<Keys, any>
function createMachine<TContext extends LucyKnownContext<KnownContextKeys>, TEvent extends { type: EventNames } = any>() {
return {} as any
View docs.md

This is some docs

Something I want to test below...

const foo = 'bar';