Skip to content

Instantly share code, notes, and snippets.

@defunctzombie
defunctzombie / browser.md
Last active July 15, 2024 04:13
browser field spec for package.json
@mathiasbynens
mathiasbynens / deterministic-math-random.js
Last active May 16, 2024 12:37
Here’s a 100% deterministic (predictable) alternative to `Math.random`. Useful when benchmarking.
// Here’s a 100% deterministic alternative to `Math.random`. Google’s V8 and
// Octane benchmark suites use this to ensure predictable results.
Math.random = (function() {
var seed = 0x2F6E2B1;
return function() {
// Robert Jenkins’ 32 bit integer hash function
seed = ((seed + 0x7ED55D16) + (seed << 12)) & 0xFFFFFFFF;
seed = ((seed ^ 0xC761C23C) ^ (seed >>> 19)) & 0xFFFFFFFF;
seed = ((seed + 0x165667B1) + (seed << 5)) & 0xFFFFFFFF;
@bradcrawford
bradcrawford / feedly_export_saved_for_later
Last active February 26, 2024 07:07
Simple script that exports a users "Saved For Later" list out of Feedly as a JSON string
// Simple script that exports a users "Saved For Later" list out of Feedly
// as a JSON string.
//
// This was intended for use in the Google Chrome's "Inspector" tool so your
// mileage may vary if used in other contexts.
//
// Format of JSON is as follows:
// [
// {
// title: "Title",
@saibotsivad
saibotsivad / indentation.md
Last active December 1, 2016 15:13
The right way to indent

The "correct" way to indent

The issue of tabs-vs-spaces is a long and revered Flame War, so I don't think I'll be changing any minds with what I can write on the topic.

However, it's what I use in all the code that I personally write, and any projects I make public use it.

When to tab

@ArtskydJ
ArtskydJ / davidr.bat
Last active February 13, 2016 23:15
git pull all repos in a directory
@echo off
FOR /D %%F in ("*") DO @(
cd %~dp0%%F
if exist "package.json" (
david > nul 2>&1 || echo %%F
)
)
@cd %~dp0
@WebReflection
WebReflection / on.js
Last active March 27, 2021 19:10
The smallest, cross browser, DOM chainable `.on()` shortcut for `addEventListener`
(function (F, I, X, DOM, on) {
DOM = (F.Node || F.Element).prototype;
on = F.Object.defineProperty ||
function (t, k, d) {
t[k] = d.value;
};
I in F || on(F, I, X);
I in DOM || on(DOM, I, X);
I in F.document || on(F.document, I, X);
}(
@njbotkin
njbotkin / DCC-bulk-download-bookmarklet.js
Last active January 25, 2018 04:46
Download DCC sermons in bulk
javascript:%22use%20strict%22;(function(){function%20e(e){var%20t=document.createElement(%22textarea%22);return%20t.innerHTML=e,t.value}var%20t=document.body.innerText.match(/%3Citem%3E[\s\S]*%3F%3C\/item%3E/g).reverse().reduce(function(t,c,n){var%20l=(%2200%22+(n+1)).slice(-3),a=e(c.match(/%3Ctitle%3E(%3F:[^%3C]+)%3F%3C\/title%3E/g).pop().slice(7,-8)),o=c.match(/%3Cenclosure%20url=%22([^%22]+)%22/).pop().replace(%22%26amp;%22,%22%26%22),i=new%20Date(c.match(/%3CpubDate%3E([^%3C]+)%3C\/pubDate%3E/g).pop().slice(9,-10)).toISOString().split(%22T%22)[0],r=l+%22_%22+i+%22_%22+a;return%20t+='%3Cdiv%3E%3Cinput%20type=%22checkbox%22%20checked%3E%26nbsp;%26nbsp;%3Ca%20href=%22'+o+'%22%20download=%22'+r+'.mp3%22%3E'+r+%22%3C/a%3E%3C/div%3E%22},%22%22),c=document.createElement(%22script%22);c.innerHTML='function%20setAll(bool)%20{Array.prototype.slice.call(document.getElementsByTagName(%22input%22)).forEach(e%20=%3E%20{e.checked%20=%20bool})}function%20clickAll()%20{Array.prototype.slice.call(document.getElementsByTagN
@TehShrike
TehShrike / eslint cli arguments.txt
Last active August 11, 2022 16:11
Ignore fixable eslint rules
eslint --rule 'no-extra-boolean-cast: 0' --rule 'no-extra-parens: 0' --rule 'no-extra-semi: 0' --rule 'no-regex-spaces: 0' --rule 'no-unsafe-negation: 0' --rule 'curly: 0' --rule 'dot-location: 0' --rule 'dot-notation: 0' --rule 'eqeqeq: 0' --rule 'no-else-return: 0' --rule 'no-extra-bind: 0' --rule 'no-extra-label: 0' --rule 'no-floating-decimal: 0' --rule 'no-implicit-coercion: 0' --rule 'no-multi-spaces: 0' --rule 'no-unused-labels: 0' --rule 'no-useless-return: 0' --rule 'wrap-iife: 0' --rule 'yoda: 0' --rule 'strict: 0' --rule 'no-undef-init: 0' --rule 'array-bracket-newline: 0' --rule 'array-bracket-spacing: 0' --rule 'array-element-newline: 0' --rule 'block-spacing: 0' --rule 'brace-style: 0' --rule 'capitalized-comments: 0' --rule 'comma-dangle: 0' --rule 'comma-spacing: 0' --rule 'comma-style: 0' --rule 'computed-property-spacing: 0' --rule 'eol-last: 0' --rule 'func-call-spacing: 0' --rule 'function-paren-newline: 0' --rule 'implicit-arrow-linebreak: 0' --rule 'indent: 0' --rule 'jsx-quotes: 0' --ru