Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
nathanhammond / rollup-funnel.js
Last active February 11, 2024 23:00
Funnel which includes only the modules identified by rollup.
var path = require('path');
var Funnel = require('broccoli-funnel');
var Plugin = require('broccoli-plugin');
var rollup = require('rollup').rollup;
var amdNameResolver = require('amd-name-resolver').moduleResolve;
var existsSync = require('exists-sync');
// Create a subclass RollupFunnel derived from Plugin
RollupFunnel.prototype = Object.create(Plugin.prototype);
RollupFunnel.prototype.constructor = RollupFunnel;
@nathanhammond
nathanhammond / textareadiff.js
Created August 27, 2010 21:55
Simple textarea diff functionality.
/*
* Textarea Diff
* Simple textarea diff functionality.
*
* Copyright 2010, Nathan Hammond
* Released under the MIT License
*/
function diff(oldtext, newtext) {
// Only one difference. Guaranteed contiguous.
@nathanhammond
nathanhammond / machine.js
Created August 19, 2020 06:39
Generated by XState Viz: https://xstate.js.org/viz
(function (xstate, constants) {
'use strict';
/**
* Leaf state condition generator.
*
* @param {String} target the target state
*/
function matchLeafState(target) {
return {
@nathanhammond
nathanhammond / kCantonese.diff
Last active July 7, 2021 11:33
Comparing pronunciations from JPTableFull.pdf and Unihan kCantonese.
diff --git a/JPTableFull.pdf b/kCantonese.txt
--- a/JPTableFull.pdf
+++ b/kCantonese.txt
-U+3439 㐹 kCantonese ngat6 1
-U+3439 㐹 kCantonese at6 2
+U+3439 㐹 kCantonese hei3
-U+3529 㔩 kCantonese ap1 1
-U+3529 㔩 kCantonese ngap1 2
@nathanhammond
nathanhammond / Emscripten OS X.md
Created March 4, 2012 21:48
How to get Emscripten running on OS X.

Running emscripten on OS X

There are a number of additional dependencies required for getting things installed on OS X. Starting with a blank slate OS X machine, this is the process it takes:

# Install Xcode Command Line Tools

# Install Homebrew
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
@nathanhammond
nathanhammond / state-machine.js
Created August 27, 2020 09:07
XState Next test case
/*
Run against HEAD of `next`.
The console output will likely make the order of operations clear, it is designed to try and guide you through the behavior.
Two issues:
- The first invoked promise does not trigger a done event, so the timeout catches and that state node re-enters.
- The `assign` for the later state (spawn) is running before an action for the previous state (reset).
One curiousity:
var windowId = 0;
function windowManager() {
return Machine({
id: 'window-manager',
initial: 'idle',
type: 'parallel',
states: {
idle: {
@nathanhammond
nathanhammond / controllers.application.js
Last active October 16, 2018 18:36
Checked Binding
import Ember from 'ember';
export default Ember.Controller.extend({
radioValue: 'one',
display: Ember.computed('radioValue', function() {
return JSON.stringify(this.get('radioValue'));
}),
actions: {
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});