Skip to content

Instantly share code, notes, and snippets.

@jfet97
jfet97 / _objectsFlattening.js
Last active June 12, 2019 23:02
objects flattening
const obj = { a: { b: 1, c: 2, d: { e:4 , f:[1,2,3,4,5,6,7,8,9,0]} }, g:42 };
const res = Object.fromEntries(flatProps(objectRecursiveEntries(obj)));
/*
{
"a.b": 1,
"a.c": 2,
"a.d.e": 4,
"a.d.f.0": 1,
"a.d.f.1": 2,

Time Travel Debugging

Time Travel refers to the ability to record a tab and later replay it ([WebReplay][wrr]). The technology is useful for local development, where you might want to:

  • pause and step forwards or backwards
  • pause and rewind to a prior state
  • rewind to the time a console message was logged
  • rewind to the time an element had a certain style or layout
  • rewind to the time a network asset loaded
@flesch
flesch / starredRepositories.graphql
Created May 3, 2018 04:01
starredRepositories.graphql
query starredRepositories($repositories: Int = 10, $after: String, $releases: Int = 1) {
viewer {
starredRepositories(first: $repositories, after: $after, ownedByViewer: false, orderBy: {field: STARRED_AT, direction: DESC}) {
pageInfo {
hasNextPage
endCursor
}
edges {
cursor
starredAt
@tegansnyder
tegansnyder / Preventing-Puppeteer-Detection.md
Created February 23, 2018 02:41
Preventing Puppeteer Detection

I’m looking for any tips or tricks for making chrome headless mode less detectable. Here is what I’ve done so far:

Set my args as follows:

const run = (async () => {

    const args = [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-infobars',
@KwanEsq
KwanEsq / deMozLz4.js
Created October 9, 2017 21:16
Decompress mozlz4 in Firefox's browser console
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Paste the function into the browser console then call
* deMozLz4(${path/to/file})
*/
async function deMozLz4(path) {
const src = await OS.File.read(path, {compression: "lz4"});
await OS.File.writeAtomic(`${path}.out`, src)
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@zenparsing
zenparsing / combinators-with-async-generators.js
Created April 8, 2016 20:57
Combinators with Async Generators
function once(el, event) {
return new Promise((resolve, reject) => {
const handler = e => {
resolve(e);
el.removeEventListener(event, handler);
};
el.addEventListener(event, handler);
});
};
@webinista
webinista / array.chunk.js
Last active March 29, 2023 23:02
Array.prototype.chunk: Splits an array into an array of smaller arrays containing `groupsize` members
/*
Split an array into chunks and return an array
of these chunks.
With kudos to github.com/JudeQuintana
This is an update example for code I originally wrote 5+ years ago before
JavaScript took over the world.
Extending native objects like this is now considered a bad practice, so use
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");