Skip to content

Instantly share code, notes, and snippets.

View spac3unit's full-sized avatar

Denis spac3unit

View GitHub Profile
@spac3unit
spac3unit / .eslintrc.js
Created September 28, 2018 12:47 — forked from dmnsgn/.eslintrc.js
.eslintrc Google JavaScript Style Guide (eslint v0.24.1)
{
// http://eslint.org/docs/rules/
"env": {
"browser": true, // browser global variables.
"node": false, // Node.js global variables and Node.js-specific rules.
"worker": false, // web workers global variables.
"amd": false, // defines require() and define() as global variables as per the amd spec.
"mocha": false, // adds all of the Mocha testing global variables.
"jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0.
@spac3unit
spac3unit / gzipped-size.js
Created October 8, 2018 00:53 — forked from davidgilbertson/gzipped-size.js
Get the size a file will be when gzipped
const fs = require('fs');
const zlib = require('zlib');
const file = fs.readFileSync('./some_file.js');
const rawSize = file.length;
const gzippedSize = zlib.gzipSync(file).length;
console.log('Raw size: ', (rawSize / 1000), 'KB');
console.log('Gzipped size: ', (gzippedSize / 1000), 'KB');
console.log('Compression: ', `${100 - Math.round(gzippedSize / rawSize * 1000) / 10}%`);
function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
Array.from(document.querySelectorAll('a'))
.map(el => el.origin)
.filter(origin => origin !== document.origin)
.filter(Boolean);
@spac3unit
spac3unit / contains.js
Created October 8, 2018 00:54 — forked from davidgilbertson/contains.js
Modal click outside
const handleClick = e => {
if (!modalEl.contains(e.target)) modalEl.hidden = true;
};
Array.from(document.getElementsByTagName('a')).forEach(el => {
console.log(el.href);
});
document.querySelector(document.location.hash).scrollIntoView();
myElement.closest('article').querySelector('h1');
el.classList.toggle('some-orange-class', theme === 'orange');
const signIn = async (username) => {
let currentPasswordIndex = 0;
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.reddit.com/login');
// Runs once for each username/password combo
const tryPassword = async () => {