Skip to content

Instantly share code, notes, and snippets.

@spiffytech
spiffytech / components.ts
Created Dec 16, 2020
Experimental HTML custom element library
View components.ts
import * as h from "hyperscript";
import morphdom from "morphdom";
import { nanoid } from "nanoid";
abstract class Coordinator<
Attrs extends Record<string, any> | null,
State extends Record<string, any>
> extends HTMLElement {
static readonly forwardedAttrs: Map<string, unknown> = new Map();
static attrsAttr = "data-attrs";
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@spiffytech
spiffytech / index.js
Last active Oct 1, 2015
requirebin sketch
View index.js
var beautify = require('js-beautify').js_beautify;
var pretty = require("js-object-pretty-print").pretty;
function show(el, val) {
document.getElementById(el).innerHTML = pretty(val, 4, "HTML");
}
// Declare our initial value
var original = {
a: 1,
@spiffytech
spiffytech / websharper.patch
Last active Aug 29, 2015
Patches an F# Scaffold project with basic WebSharper support
View websharper.patch
diff --git a/Web.config b/Web.config
new file mode 100644
index 0000000..053354f
--- /dev/null
+++ b/Web.config
@@ -0,0 +1,358 @@
+<configuration>
+ <configSections>
+ <sectionGroup name="elmah">
+ <!-- NOTE! If you are using ASP.NET 1.x then remove the
@spiffytech
spiffytech / import.rb
Last active Jun 2, 2021 — forked from evanwalsh/import.rb
Imports a Squarespace dump into Jekyll
View import.rb
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'nokogiri'
require 'fileutils'
require 'safe_yaml'
require 'time'
require 'uri'
require 'open-uri'
View keybase.md

Keybase proof

I hereby claim:

  • I am spiffytech on github.
  • I am spiffytech (https://keybase.io/spiffytech) on keybase.
  • I have a public key whose fingerprint is 0528 73D9 49FE B3AC 3734 C80A 5243 7EC7 D25A CEB9

To claim this, I am signing this object:

@spiffytech
spiffytech / attr_replace.py
Last active Aug 29, 2015
Replaces nested attributes on namedtuples
View attr_replace.py
def attr_update(obj, child=None, _call=True, **kwargs):
'''Updates attributes on nested namedtuples.
Accepts a namedtuple object, a string denoting the nested namedtuple to update,
and keyword parameters for the new values to assign to its attributes.
You may set _call=False if you wish to assign a callable to a target attribute.
Example: to replace obj.x.y.z, do attr_update(obj, "x.y", z=new_value).
Example: attr_update(obj, "x.y.z", prop1=lambda prop1: prop1*2, prop2='new prop2')
Example: attr_update(obj, "x.y", lambda z: z._replace(prop1=prop1*2, prop2='new prop2'))