Skip to content

Instantly share code, notes, and snippets.

View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View keybase.md

Keybase proof

I hereby claim:

  • I am zzzzbov on github.
  • I am zzzzbov (https://keybase.io/zzzzbov) on keybase.
  • I have a public key ASCm3sWFZGZjBe02ULVLFL8z5Ol7QjOurYanaep5_uwceQo

To claim this, I am signing this object:

View toFixed.js
toFixed = (value, fractionDigits) => {
const f =
fractionDigits === undefined
? 0
: +fractionDigits
console.log('1. f:', f)
if (f < 0 || f > 20) {
console.error('2. throw a RangeError')
@zzzzBov
zzzzBov / JavaScript Profiler
Last active Sep 16, 2017
A small script to profile JS and dump the data to the console.
View JavaScript Profiler
class Profiler {
constructor (name) {
this._name = name
this._profiles = []
this._activeProfiles = this._profiles
}
profile (name, fn) {
if (typeof name !== 'string') {
throw new TypeError('"name" must be a string')
@zzzzBov
zzzzBov / Saveable Form
Last active Dec 18, 2015
Flag unsaved changes when a user leaves a page with a saveable form
View Saveable Form
(function (root, $) {
"use strict";
$('[data-saveable]').on('change', ':input', function () {
//flag the form as having changed
$(this).closest('[data-saveable]').data('saveable', true);
}).on('submit', function (e) {
//if the form is successfully being submitted, it's probably being saved
if (!e.isDefaultPrevented()) {
//force the saveable input to lose focus
//to trigger any possible change events
@zzzzBov
zzzzBov / resizeelement
Created Jun 2, 2013
resizeelement cutsom jQuery event
View resizeelement
(function (root, $) {
"use strict";
$.event.special.resizeelement = {
setup: function () {
var $this,
interval,
width,
height;
$this = $(this);
width = $this.width();
@zzzzBov
zzzzBov / index.html
Created Aug 10, 2012
A web page created at CodePen.io.
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->
@zzzzBov
zzzzBov / index.html
Created Jul 9, 2012
A web page created at CodePen.io
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Simple button &middot; CodePen</title>
<!--
Copyright (c) 2012 zzzzBov, http://codepen.io/zzzzBov
Permission is hereby granted, free of charge, to any person obtaining