This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throttle(fn, duration) { | |
var t; | |
return function(...args) { | |
clearTimeout(t); | |
t = setTimeout(fn.bind(null, ...args), duration); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM This command will export all wifi profiles into individual XML files | |
netsh wlan export profile key=clear |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Polyfill for createImageBitmap | |
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap | |
* | |
* Supports CanvasImageSource (img, video, canvas) sources, Blobs, and ImageData. | |
* | |
* From: | |
* - https://dev.to/nektro/createimagebitmap-polyfill-for-safari-and-edge-228 | |
* - https://gist.github.com/MonsieurV/fb640c29084c171b4444184858a91bc7 | |
* Updated by: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const totalSize = Object.values(localStorage).reduce((acc, c) => acc += c.length, 0); | |
const length = Object.values(localStorage).length; | |
console.log(`${length} entries using ${totalSize} bytes (${Math.floor(totalSize/length)} bytes/entry)`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<div class="message"></div> | |
<script src="script.js"></script | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
'use strict'; | |
var engines = { | |
bing: 'https://www.bing.com/search?q=', | |
duckduckgo: 'https://duckduckgo.com/?q=', | |
google: 'https://www.google.com/search?q=' | |
}; | |
var engine = engines.duckduckgo; // Change to specify a different search engine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery-like syntactic sugar. Only queries for one element. Does not loop over multiple like jQuery | |
export function $(query) { | |
if (typeof query === 'undefined') throw 'No query provided to $'; | |
var el; | |
if (typeof query.nodeType === 'string') { | |
el = query; | |
} else if (typeof query === 'string' && query[0] === '<') { | |
const container = document.createElement('div'); | |
container.innerHTML = query; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage example: document.querySelector('video').poster = createColorDataURI(50,100,150); | |
function createColorDataURI(r, g, b, a) { | |
const canvas = document.createElement('canvas'); | |
canvas.width = 1; | |
canvas.height = 1; | |
const context = canvas.getContext('2d'); | |
const imageData = context.getImageData(0, 0, 1, 1); | |
const subPixels = imageData.data; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jshint esnext:true | |
/* | |
Every JSON entry is removed if the key is "_comment". "_comment" can optionally be followed | |
by underscores, letters, or digits to make the key more unique (e.g. "_comments_name", "_comments_todo"). | |
The JSON is still valid JSON with the "_comment", and it will parse fine anywhere. It will | |
just have the extra "_comment" entries. | |
See example here: http://jsbin.com/favarow/ | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const divide = (str, divider, n) => String(str) | |
.split('') | |
.reverse() | |
.reduce((acc, cv, i) => cv + (i % n === 0 ? divider : '') + acc); | |
let num = 4000000; | |
divide(num, '|', 2); // 4|00|00|00 | |
divide(num, ',', 3); // 4,000,000 | |
divide(num, '-', 1); // 4-0-0-0-0-0-0 |