Skip to content

Instantly share code, notes, and snippets.

View newyankeecodeshop's full-sized avatar

Andrew Goodale newyankeecodeshop

View GitHub Profile
@newyankeecodeshop
newyankeecodeshop / updater.js
Last active February 6, 2018 16:46
A GongFu updater pattern
function update1(msg, model, appContext) {
// This approach uses effects to implement application logic to do other UI actions.
switch (msg.type) {
case "ButtonPressed":
if (userCanDo(msg)) {
return {
model: assocTyped("doo", doo, model),
effect: Effect(DoSomething(msg.what))
};
else
@newyankeecodeshop
newyankeecodeshop / dom-interfaces.d.ts
Created September 19, 2017 13:44
TypeScript declarations for a DOM-free React Native project
/* For react DOM */
interface Event {}
interface AnimationEvent extends Event {}
interface ClipboardEvent extends Event {}
interface CompositionEvent extends Event {}
interface DragEvent extends Event {}
interface FocusEvent extends Event {}
interface KeyboardEvent extends Event {}
interface MouseEvent extends Event {}
@newyankeecodeshop
newyankeecodeshop / ServingES6.md
Last active June 19, 2021 07:36
Serving ES6 to modern browsers

Background

Recently I noticed that Safari 10 for Mac/iOS had achieved 100% support for ES6. With that in mind, I began to look at the browser landscape and see how thorough the support in the other browsers. Also, how does that compare to Babel and its core-js runtime. According to an ES6 compatability table, Chrome, Firefox, and IE Edge have all surpassed what the Babel transpiler can generate in conjunction with runtime polyfills. The Babel/core-js combination achieves 71% support for ES6, which is quite a bit lower than the latest browsers provide.

It made me ask the question, "Do we need to run the babel es2015 preset anymore?", at least if our target audience is using Chrome, Firefox, or Safari.

It's clear that, for now, we can't create a site or application that only serves ES6. That will exclude users of Internet Explorer and various older browsers running on older iOS and Android devices. For example, Safari on iOS 9 has pretty mediocre ES6 support.

@newyankeecodeshop
newyankeecodeshop / browser-support.js
Created November 15, 2016 16:57
Browser detection for ES6 support
/**
* Detect browser capabilities on the server.
*/
var useragent = require('useragent')
var MinimumForES6 = {
"Chrome": 49,
"Edge": 14,
"Firefox": 45,
"Safari": 10
@newyankeecodeshop
newyankeecodeshop / JsonChangeExecListener.scala
Created July 21, 2015 13:07
Liquibase change listener that generates a JSON file based on the change sets executed. It uses Jackson for JSON generation.
import java.io.File
import java.sql.Timestamp
import java.util.concurrent.ConcurrentHashMap
import com.fasterxml.jackson.core.{JsonEncoding, JsonFactory}
import liquibase.change.Change
import liquibase.changelog.ChangeSet.{ExecType, RunStatus}
import liquibase.changelog.visitor.ChangeExecListener
import liquibase.changelog.{ChangeSet, DatabaseChangeLog}
@newyankeecodeshop
newyankeecodeshop / KendoGrid.js
Created July 7, 2014 16:03
New KendoGrid w/ selection support
/** @jsx React.DOM */
define([
'underscore', 'jquery', 'react', 'kendo'
], function (_, $, React, kendo) {
'use strict';
void kendo;
var PropTypes = React.PropTypes;
function isCellSelection(selectable) {