Skip to content

Instantly share code, notes, and snippets.

View cstumph's full-sized avatar

Christopher Stumph cstumph

View GitHub Profile
@rsms
rsms / fps.ts
Created November 3, 2019 20:25
FPS measurement in web browser
// measureFPS uses requestAnimationFrame to measure frame times and reports
// the average frames per second.
//
function measureFPS(report :(fps:number)=>void) {
const samplesSize = 120 // total number of frame times look at (window size)
const samples :number[] = [] // ring buffer; sliding window
const reportAt = Math.round(samplesSize / 4)
let samplesIndex = 0 // next index in samples
let prevTime = 0 // last time value; frameTime = prevTime - time
// @flow
import * as React from 'react';
// inside functional components, you can drop this hook
// and be notified when the modified component re-renders.
// this component will also tell you _why_ it was re-rendered
export default function useTraceUpdate(props: any) {
const prev = React.useRef(props);
React.useEffect(() => {
@evantahler
evantahler / buildSitemap.js
Last active December 17, 2020 16:35
35 lines to build a sitemap for next.js projects
#! /usr/bin/env node
// I am ./bin/buildSitemap.js
const path = require('path')
const glob = require('glob')
const fs = require('fs')
const SITE_ROOT = process.env.SITE_ROOT || 'https://www.actionherojs.com'
const SOURCE = process.env.SOURCE || path.join(__dirname, '..', 'pages', '/**/*.js')
const DESTINATION = process.env.DESTINATION || path.join(__dirname, '..', 'static', 'sitemap.xml')
@thefotios
thefotios / emojify.sh
Created July 21, 2015 20:30
Makes properly sized emoji for slack. Just point this at any URL. You'll need to have `convert` (part of ImageMagick)
#!/usr/bin/env bash
url=$1;
output=${2-output.png};
size=${3-128};
curl --silent -kL $url | convert - -resize ${size}x${size} $output;
@bendc
bendc / functional-utils.js
Last active September 15, 2023 12:12
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@othiym23
othiym23 / skiffy.md
Created August 10, 2014 07:56
some sf and fantasy recommendations

The Winterlong Trilogy by Elizabeth Hand

Gothic, Grand Guignol-drenched post-apocalyptic science-fantasy. "Febrile" is a word that comes to mind – the language is overstuffed, it's dense with references to fantasy and folklore, and the characters are run through the wringer. Not the last of her novels to feature a transmogrified Washington DC as a primary venue.

Waking the Moon by Elizabeth Hand

Roman á clef and supernatural romance (in the traditional, not Twilight sense) featuring the hidden war between the Benandanti, a sect of nasty old patriarchal quasi-Catholics, and the forces of Othiym Lunarsa, goddess of a long-suppressed matriarchal death cult. If Camille Paglia ever read this, she probably loved it, but the central story is basically an overheated, fantastic version of Whit Stillman's Metropolitan and so th

@mikeal
mikeal / gist:9242748
Last active June 23, 2020 05:17
Response to Nodejitsu NPM Trademark

I've known people at nodejitsu for years, since before the company even existed. I still consider many of them friends. That said, somebody over there has lost their mind.

Trademarks are an important part of open source. They protect the integrity of the trust that is built by any project. A classic example of why this is the case is Firefox. Suppose that a malware producer takes the Firefox codebase, which is free and open source, packages up their malware with it and then releases it as "Firefox". Then they buy search advertising and suddenly their bad and malicious version of Firefox is the first result on search engines across the web. This is clearly a bad thing for Firefox and open source everywhere, but what can Mozilla do to protect their community of users?

They can't enforce a software license since the use is permitted under the Mozilla Public License. They can, however, enforce on these hypothetical bad actors using their trademark on the word "Fi

@mikeal
mikeal / gist:7724521
Last active December 29, 2015 20:29
Inclusive by Exclusion

When you build a community you're creating a culture. That culture will be about more than the code, the modules, or the language. The people you draw in will have their own biases and behaviors that impact the kinds of people you continue to draw as you grow.

Cultures will naturally fight behavior that is divisive. That is, behavior that is divisive to the established members of that community. As a community grows larger it is harder and harder to change what the culture finds acceptable because changing it, even if it is inclusive in nature, is disturbing and divisive to existing membership. Fighting for change in established cultures means dealing with a lot of dismissive language and attacks for the "tone" of your argument.

That is why it is so important that a culture becomes comfortable with aggressively fighting exclusionary behavior. While it is certainly more beneficial to make pro-active steps to increase diversity we cannot be dismissive of the effect that passionate reactions to poor behavior

@thebyrd
thebyrd / example.js
Last active December 25, 2015 05:19
A method that will inject npm modules listed as parameters in a constructor.
function SomeConstructor (request, npm, monk) {
// do something with the injected node modules
}
var instance = require('./injector')(SomeConstructor) // create a new instance with dependencies injected
// Make it Nasty
function increment (i) {
i ^= (i & ~-~i) | (~i & -~i)
return i
}