Skip to content

Instantly share code, notes, and snippets.

View mholtzhausen's full-sized avatar

Mark Holtzhausen mholtzhausen

View GitHub Profile
<div id="sdialog" style="
position: absolute;
top: 200px;
left: 200px;
min-width: 390px;
overflow-x: hidden;
font-size: 13px;
color: #323232;
background-color: #e5e5e5;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
.noFlicker1{
-webkit-transform-style: preserve-3d;
}
.noFlicker2{
will-change: opacity;
}
.noFlicker3{
-webkit-transform: translateZ(0); //messes with chrome
@mholtzhausen
mholtzhausen / formInputEvents.js
Created November 23, 2016 10:32
Add form change and input change events on the document and form -- based on polling
/* global window, document, CustomEvent, console */
/**
* Polls all forms on the page and renders document events and form events
*/
(function(pollFrequency, formEventName, inputEventName, inputInitEventName) {
let formsMap = new WeakMap;
/**
* Input Change event
@mholtzhausen
mholtzhausen / curry.js
Created November 24, 2016 14:30
Curry a function
module.exports.curry = function(fn) {
return (function(fn) {
var argstack = [];
function curryFactory(size) {
if (size > 1) {
return arg => {
(size == fn.length) ? argstack = [arg] : argstack.push(arg)
return curryFactory(size - 1);
};
@mholtzhausen
mholtzhausen / index.html
Created November 25, 2016 11:44
Remove all instances of item from an array (http://jsbench.github.io/#fec618f95fedb4f152a2f682a9b3d25c) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Remove all instances of item from an array</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@mholtzhausen
mholtzhausen / index.html
Created November 25, 2016 12:18
Find the position of All Occurrances of an item in an array (http://jsbench.github.io/#199ffe05267d71b1d054ef0295d1d035) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Find the position of All Occurrances of an item in an array</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@mholtzhausen
mholtzhausen / requestanimationframe.js
Created December 9, 2016 13:11 — forked from desandro/requestanimationframe.js
requestAnimationFrame polyfill
/**
* requestAnimationFrame polyfill by Erik Möller & Paul Irish et. al.
* https://gist.github.com/1866474
*
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
* http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
**/
/*jshint asi: false, browser: true, curly: true, eqeqeq: true, forin: false, newcap: true, noempty: true, strict: true, undef: true */
@mholtzhausen
mholtzhausen / SomeClass.pvt.es6
Last active September 19, 2017 10:17
Private Variables in classes ES6
/******************************************************************** /
Sadly ES2015 does not yet offer private variables for classes.
This coding pattern allows a graceful way to define classes with
private access to isolated members.
/********************************************************************/
export const SomeClass = (() => {
const _private = new WeakMap();
class SomeClass {
constructor() {
_private.set(this, { name: '', surname: '' });
@mholtzhausen
mholtzhausen / Modal.js
Last active June 21, 2018 09:43
Modal Dialog
function tag(html){
return((html)=>{
let container=document.createElement('div')
let frag = document.createDocumentFragment()
container.innerHTML=html
Array.prototype.slice.call(container.childNodes).forEach(node=>{
console.log(`adding ${node}`)
frag.appendChild(node)
})
return frag
@mholtzhausen
mholtzhausen / Class Module.js
Last active June 26, 2018 13:37
Class Utilities
const ClassName = (() => {
// Privately Accessible Data
const instancesData = new WeakMap()
let instanceData //Stores data by instance
let classData = {} //Stores data for the class
// Privately Accessible Functions
class Pvt {
constructor() { return Pvt; }// no instantiation
static somePrivateFunction() {