Skip to content

Instantly share code, notes, and snippets.

@mshwery
mshwery / machine.js
Last active January 19, 2022 16:48
Generated by XState Viz: https://xstate.js.org/viz
const needsEmail = (context, _event) => !Boolean(context.email)
const meetsCriteria = (context, _event) => Boolean(context.email)
const widgetMachine = Machine({
id: 'widget',
initial: 'hello',
context: { email: null },
states: {
hello: {
@mshwery
mshwery / Procfile
Created May 6, 2019 13:59
Use Heroku's release feature to deploy Typescript NodeJS sourcemaps to Sentry. So you can properly debug transpiled Typescript files!
release: bash ./release-sentry.sh
web: npm start
@mshwery
mshwery / index.js
Last active November 1, 2017 15:56
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const Topo = require('topo')
const quals = [
{
Name: 'Blah',
QuestionID: 999
},
### Keybase proof
I hereby claim:
* I am mshwery on github.
* I am mshwery (https://keybase.io/mshwery) on keybase.
* I have a public key ASB75ykXbhcGdPS806ZNSNJG1Xp8t_uRa4dlXRvR0HArtQo
To claim this, I am signing this object:
@mshwery
mshwery / store.js
Last active May 7, 2018 18:14
a localStorage wrapper with time-to-live and JSON stringify/parsing
/**
* store.js
* a localStorage wrapper with time-to-live and JSON stringify/parsing
*
* @author Matt Shwery
* @license MIT (http://www.opensource.org/licenses/mit-license)
*/
store = (function () {
// polyfill for localstorage into stale storage so this data store doesnt ever fail
[
{
"requested_at":"2014-9-5 00:17:10.0",
"port":52251,
"ip":"80.1.150.234",
"response_time":0.114823,
"path":"router/RespondentAuthentication.aspx?SID=e8f8cbf4-2bbf-4d76-9519-52aed9fa6554&PID=EPO4YTQ8DRBKYXY434&RVCID=&RVPID=&RVSID=&RVTO=&RVID=",
"rcvd":11,
"statuscode":200,
"method":"POST",
@mshwery
mshwery / app.js
Last active May 6, 2024 05:27
Gulp + Browserify + requiring .html templates + Knockout web components
var ko = require('knockout');
ko.components.register('simple-name', require('./components/simple-name/simple-name.js'));
ko.applyBindings({ userName: ko.observable() });
@mshwery
mshwery / README.md
Last active August 29, 2015 14:01 — forked from mbostock/.block
Pie Chart v2

This pie chart is constructed from a JSON file storing the populations of various age groups. The chart employs a number of D3 features:

@mshwery
mshwery / LocalStore.js
Last active August 29, 2015 14:00
Wrapper to add optional TTL for localStorage.
// polyfill for localstorage into stale storage so this data store doesnt ever fail
if (!('localStorage' in window)) {
//if (!Modernizr.localstorage) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
removeItem : function(id) { return delete this._data[id]; },
clear : function() { return this._data = {}; }
};
@mshwery
mshwery / shynav.js
Last active April 18, 2018 00:27
Shynav Plugin. This is a little plugin that hides/shows the nav based on scrolling. It's decoupled from the styles, so you are left to implement whatever styles meet the needs of a nav when scrolled, detached from the top, and hidden.
$.fn.shynav = function(opts) {
var elem = this;
var defaults = {
delay: 4000, // how long til shynav gets shy
minScroll: $(elem).height() || 0, // how far user scrolls before shynav does its thing
detachedClass: 'scrolled', // what class does the element get when scrolled
hiddenClass: 'hidden' // what class does the element get when hidden
};