Skip to content

Instantly share code, notes, and snippets.

nathanhoel / logger.js
Last active Dec 14, 2016
Halite node.js logger module
View logger.js
const loggerOn = 0;
var winston = null;
try {
winston = require('winston');
filename: 'match.log',
hello-josh / crawler.go
Last active Dec 6, 2019
A Tour of Go - Exercise: Web Crawler
View crawler.go
package main
import (
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
nixel2007 /
Created Jan 22, 2016
save as utf-8-bom in atom
atom.workspace.observeTextEditors (editor) ->
editor.onDidSave ->
if editor.getPath().slice(-3) is '.os'
if editor.getEncoding() is 'utf8' and editor.getText().charCodeAt(0) isnt 65279
editor.setText String.fromCharCode(65279) + editor.getText()
paulirish /
Last active Sep 21, 2021
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
royling / interweave.js
Last active Feb 25, 2018
Interweave arrays
View interweave.js
// inspired when reading
// this is the behavior that template tags may interweave literals and subsitutions arrays
var interweave = (a, b) => {
let min = Math.min(a.length, b.length);
return Array.apply(null, Array(min)).reduce((result, value, index) => {
result.push(a[index], b[index]);
return result;
}, []).concat((a.length > min ? a : b).slice(min));
tyler-johnson / asyncwhile.js
Created Oct 14, 2014
Asynchronous while loop for ES6 Promises.
View asyncwhile.js
function asyncWhile(condition, action, ctx) {
var whilst = function(data) {
return, data) ?
Promise.resolve(, data)).then(whilst) :
return whilst();