Skip to content

Instantly share code, notes, and snippets.

@matthewp
matthewp / mastodon-status
Last active March 29, 2023 19:17
A bash script for posting statuses to Mastodon
#!/bin/bash
usage() {
program_name=$(basename $0)
bold=$(tput bold)
normal=$(tput sgr0)
cat <<EOM
Usage: $program_name [options] status
Post a status update to a Mastodon account.
@matthewp
matthewp / steal.js
Created June 26, 2018 19:31
steal.js with fix
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/** @license MIT License (c) copyright 2010-2014 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
/**
* ES6 global Promise shim
*/
var unhandledRejections = require('../lib/decorators/unhandledRejection');
var PromiseConstructor = unhandledRejections(
@matthewp
matthewp / constants.js
Last active July 20, 2022 19:55
FSM DSL
export const HOLE = 'hole';
export const ASSIGN = 'assign';
@matthewp
matthewp / example.html
Created June 12, 2019 12:01
Observed attributes dynamic
<!doctype html>
<html lang="en">
<title>Some title</title>
<my-element id="myel"><my-element>
<script type="module">
class MyElement extends HTMLElement {
static get observedAttributes() {
let defines = this.define;
@matthewp
matthewp / rel-template.js
Created June 19, 2012 19:08
Synchronous loading of templates in a link tag.
(function() {
"use strict";
Object.defineProperty(HTMLLinkElement.prototype, 'template', {
get: function() {
if(!/template/i.test(this.rel)) {
return "";
}
var req = new XMLHttpRequest();
@matthewp
matthewp / pnpm-where
Created March 9, 2022 13:49
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
@matthewp
matthewp / 00explainer.md
Last active December 1, 2021 19:20
SSR discovery
@matthewp
matthewp / parser.md
Last active October 29, 2021 15:08
Binding DSL

Memory layout

1 imported page

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

Internal

@matthewp
matthewp / lit-haunted-element.js
Last active October 17, 2021 15:52
Haunted State Integration
import { LitElement } from 'lit-element';
import { State } from 'haunted';
export default class LitHauntedElement extends LitElement {
constructor() {
super();
this.hauntedState = new State(() => this.requestUpdate(), this);
}
@matthewp
matthewp / readme.md
Created September 17, 2021 17:17
streaming tests
deno run --allow-net --unstable server.js