Skip to content

Instantly share code, notes, and snippets.

View pvdz's full-sized avatar

Peter van der Zee pvdz

View GitHub Profile
@pvdz
pvdz / timesum.v0.js
Created May 25, 2020 09:14
timeSum, tiny addition to console to measure aggregated time used between two calls and print them and some maintenance around it. ymmv. assumes `console` is global across modules, like it is in nodejs. require once use anywhere
const { performance } = require("perf_hooks")
let running = new Map()
let data = new Map()
let timeNames = new Set()
console.timeSum = function _timeSum(name, callback) {
if (running.has(name)) {
return console.warn("console.timeSum: name already being recorded:", name)
}
@pvdz
pvdz / gist:554d99585099c4f5131b5e88b55fdae4
Created March 30, 2020 12:12
cache contentful data; gatsby clean; `CI=1 GATSBY_REMOTE_CACHE=./path/to/remotecache node --max_old_space_size=12288 ./node_modules/.bin/gatsby build`
const path = require(`path`)
const v8 = require(`v8`)
const fs = require(`fs`)
const contentful = require(`contentful`)
const _ = require(`lodash`)
const chalk = require(`chalk`)
const normalize = require(`./normalize`)
const { formatPluginOptionsForCLI } = require(`./plugin-options`)
@pvdz
pvdz / gist:a26acfde5bf309b8a0717ba2dd9250e4
Created January 28, 2020 10:07
daneden plain yarn cold
😶 11:04:20 (master) ~/gatsby/daneden.me $ gatsby build
success open and validate gatsby-configs - 0.154s
success load plugins - 0.603s
success onPreInit - 0.003s
success delete html and css files from previous builds - 0.011s
success initialize cache - 0.008s
success copy gatsby files - 0.021s
success onPreBootstrap - 0.016s
success createSchemaCustomization - 0.002s
warn code block or inline code language not specified in markdown. applying generic code block
@pvdz
pvdz / submoduiles.js
Created September 24, 2017 08:54
Silly mocha+babel problem with relative imports outside project root
How do you mocha+babel test projectA as is?
Note that projectB also its own mocha+babel tests which run fine (but they do not need to run here).
// ..../somedir/projectA/src/index.js
import {x} from '../../projectB/src/index.js';
...
// ..../somedir/projectB/src/index.js
import {x} from './tools.js';
@pvdz
pvdz / verifier.js
Created August 24, 2017 17:12
This takes an fdq input problem, solves it, and confirms the result is correct. I use it to test whether transformation tricks are valid, where I don't care about the actual results as long as they are valid. This will automate this process, prevent me from having to write a zillion results by hand, and of course maintain them as they can change…
import Solver from '../../src/solver';
import {
domain__debug,
domain_arrToSmallest,
domain_createValue,
domain_divby,
domain_intersection,
domain_mul,
} from '../../src/domain';
import domain_plus from '../../src/doms/domain_plus';
@pvdz
pvdz / verifier.js
Created August 24, 2017 17:12
This takes an fdq input problem, solves it, and confirms the result is correct. I use it to test whether transformation tricks are valid, where I don't care about the actual results as long as they are valid. This will automate this process, prevent me from having to write a zillion results by hand, and of course maintain them as they can change…
import Solver from '../../src/solver';
import {
domain__debug,
domain_arrToSmallest,
domain_createValue,
domain_divby,
domain_intersection,
domain_mul,
} from '../../src/domain';
import domain_plus from '../../src/doms/domain_plus';
@pvdz
pvdz / verifier.js
Created August 24, 2017 17:12
This takes an fdq input problem, solves it, and confirms the result is correct. I use it to test whether transformation tricks are valid, where I don't care about the actual results as long as they are valid. This will automate this process, prevent me from having to write a zillion results by hand, and of course maintain them as they can change…
import Solver from '../../src/solver';
import {
domain__debug,
domain_arrToSmallest,
domain_createValue,
domain_divby,
domain_intersection,
domain_mul,
} from '../../src/domain';
import domain_plus from '../../src/doms/domain_plus';
Statement -> ExpressionStatement -> Expression -> AssignmentExpression ->
AssignmentExpression -> ConditionalExpression -> LogicalORExpression -> LogicalANDExpression ->
BitwiseORExpression -> BitwiseXORExpression -> BitwiseANDExpression -> EqualityExpression ->
RelationalExpression -> ShiftExpression -> AdditiveExpression -> MultiplicativeExpression
MultiplicativeExpression -> MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
MultiplicativeOperator -> one of * / %
// We can match * on MultiplicativeOperator, continue left and right up to PrimaryExpression
// proceeding to match the arrow on the right side
ExponentiationExpression -> UnaryExpression -> UpdateExpression -> LeftHandSideExpression -> NewExpression ->
@pvdz
pvdz / build.js
Last active December 9, 2016 11:08
failing babili on this finitedomain build at bbc7aeecd2b1fee7409d8ddd46e8f78091bcaaaf (grunt distq, ./node_modules/.bin/babili build/finitedomain.es6.concat.js -o foo.js)
let Solver = (function(){
// from: src/config.js
/**
* @returns {$config}
*/
function config_create() {
let config = {
@pvdz
pvdz / gist:26473dd35c9ebd04d8a089fc0cd319d3
Created August 20, 2016 07:33
mass steam confirmation clicking in gmail (through console)
var e = document.createElement('div');
e.innerHTML = Array.from(document.body.querySelectorAll('a[href^="https://steamcommunity.com/market/confirmlisting/"]'))
.filter(e => e.href.indexOf('cancel') < 0)
.map(e => '<a href="'+e.href+'" onclick="p=this.parentNode;p.removeChild(this.nextElementSibling);p.removeChild(this);if(!p.children.length)p.parentNode.removeChild(p);">'+e.href+'</a><br>')
.join('\n');
document.body.appendChild(e);
e.style.position = 'absolute';
e.style.top = 0;
e.style.backgroundColor='white';
e.style.border='1px solid black';