Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@Munter
Munter / check-jspm-config.js
Created July 7, 2015 12:34
Small script to automatically verify that a jspm package has been correctly installed and configured
var jspm = require('../package.json').jspm;
var jsdom = require('jsdom');
var async = require('async');
var chalk = require('chalk');
var express = require('express');
var app = express();
app
.get('*.html', function (req, res) {
@brycebaril
brycebaril / output.md
Last active February 23, 2020 22:35
process.nextTick vs setImmediate

@mafintosh asks: "Does anyone have a good code example of when to use setImmediate instead of nextTick?"

https://twitter.com/mafintosh/status/624590818125352960

The answer is "generally anywhere outside of core".

process.nextTick is barely asynchronous. Flow-wise it is asynchronous, but it will trigger before any other asynchronous events can (timers, io, etc.) and thus can starve the event loop.

In this script I show a starved event loop where I just synchronously block, use nextTick and setImmediate

@paulirish
paulirish / what-forces-layout.md
Last active November 3, 2025 14:02
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
@gaearon
gaearon / slim-redux.js
Last active September 7, 2025 15:41
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@paullewis
paullewis / requestIdleCallback.js
Last active April 23, 2025 04:07
Shims rIC in case a browser doesn't support it.
/*!
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

general

Keys Action Description
Cmd-Shift-A Search action by name search for any command/menu items
Alt-F1 Select target Open current file in project tree, finder, etc

opening files

Keys Action Description
Cmd-O Class search classes, traits, objects
gstash() {
local out k reflog
out=(
$(git stash list --pretty='%C(yellow)%gd %>(14)%Cgreen%cr %C(blue)%gs' |
fzf --ansi --no-sort --header='enter:show, ctrl-d:diff, ctrl-o:pop, ctrl-y:apply, ctrl-x:drop' \
--preview='git stash show --color=always -p $(cut -d" " -f1 <<< {}) | head -'$LINES \
--preview-window=down:50% --reverse \
--bind='enter:execute(git stash show --color=always -p $(cut -d" " -f1 <<< {}) | less -r > /dev/tty)' \
--bind='ctrl-d:execute(git diff --color=always $(cut -d" " -f1 <<< {}) | less -r > /dev/tty)' \
--expect=ctrl-o,ctrl-y,ctrl-x))
@dekz
dekz / fstash.zsh
Last active April 8, 2025 08:19
fzf + git stash
fstash() {
local out q k sha
while out=$(
git stash list --pretty="%C(yellow)%h %>(14)%Cgreen%cr %C(blue)%gs" |
fzf --ansi --no-sort --query="$q" --print-query \
--expect=ctrl-d,ctrl-b);
do
IFS=$'\n'; set -f
lines=($(<<< "$out"))
unset IFS; set +f
@srdjan
srdjan / 100+ different counter apps...
Last active August 28, 2025 18:36
100+ different js counter apps...
100+ different js counter apps...
@threepointone
threepointone / ensure.js
Last active January 13, 2022 10:10
fix for ssr + dynamic imports with webpack
function ensure(moduleId, fn, done){
if(__webpack_modules__[moduleId]) { //eslint-disable-line no-undef
return done(undefined, __webpack_require__(moduleId)) //eslint-disable-line no-undef
}
fn().then(Module => done(undefined, Module), done)
}
// usage
ensure(require.resolveWeak('./x.js'),