Skip to content

Instantly share code, notes, and snippets.

@kidGodzilla
kidGodzilla / invert-binary-tree.js
Created May 28, 2016 19:42
Invert a Binary Tree in Javascript
// This problem was inspired by this original tweet by Max Howell:
// Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.
// So, let's invert a binary tree in Javascript
// Original Tree
// 4
// / \
// 2 7
// / \ / \
<?php
/**
*
* Plugin fires OnWebPagePrerender system event, loads Minify HTML by Mr Clay and minifies the requested Resource HTML inc. inline css and js.
*
* If used in conjunction with StatCache the minified HTML is cached and served as a flat file via IIS Rewrite.
*
* CREDITS
*
* http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins
@MoOx
MoOx / isDblTouchTap.js
Last active April 30, 2023 19:28
Double touch tap workaround for React based on onTouchTap (react-tap-event-plugin)
const dblTouchTapMaxDelay = 300
let latestTouchTap = {
time: 0,
target: null,
}
export default function isDblTouchTap(event) {
const touchTap = {
time: new Date().getTime(),
target: event.currentTarget,
@jareware
jareware / README.md
Last active June 7, 2018 04:12
Quick PSA on icon fonts and ligatures

Long Live Icon Fonts!

or, a Quick PSA on icon fonts and ligatures.

tl;dr: keep using icon fonts, they are nice, just enable ligatures

These are my talking notes at the http://wwweeklies.com/ on 2015-12-04:

function loadSVG( url ) {
// AJAX-y load the SVG icon
var req = new XMLHttpRequest();
req.onload = serializeSVG;
req.open( 'get', url, true );
req.send( null );
}
function serializeSVG() {
@WebReflection
WebReflection / String.prototype.template.js
Last active August 17, 2022 04:04
ES6 Template like strings in ES3 compatible syntax.
// this is now a module:
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});
@christianseel
christianseel / introRTE
Created August 14, 2014 14:52
RTE for introtext #modx
<?php
// Add RTE for introtext if richtext option is enabled for the resource
// check "OnDocFormRender" event
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function() {
if(MODx.loadRTE) MODx.loadRTE("modx-resource-introtext");
});</script>');
@cvrebert
cvrebert / survey.md
Last active July 5, 2022 16:20
Click and focus behavior across browsers & OSes

Test apparatus: http://jsfiddle.net/hRub4/

(Windows = Windows 8.1 desktop)

  • Windows Chrome 39
    • Button focuses on click and via keyboard tabbing
    • Anchor focuses on click and via keyboard tabbing
  • Windows Firefox 30.0
    • Button focuses on click and via keyboard tabbing
    • Anchor focuses on click and via keyboard tabbing
  • Windows Internet Explorer 11
@evaisse
evaisse / object.toquerystring.js
Last active October 19, 2017 00:09
Object.toQueryString - Vanilla JS version - encode object to POST, GET AJAX calls
/**
* Simply encode a base js object as {a:2, d:[1,"two"], c: {foo: {bar:1}}}
* And returns URL encoded string : a=2&d[0]=1&d[1]=two&c[foo][bar]=1"
*
* @param {Object} object A base javascript object : {}
* @param {String} base Optionnal base notation, should only be used by recursion for internal work
* @return {String} URL encoded query string
*/
Object.toQueryString = function (object, base) {
var queryString = [];