Skip to content

Instantly share code, notes, and snippets.

View akx's full-sized avatar
👹
rer

Aarni Koskela akx

👹
rer
View GitHub Profile
@akx
akx / run-tasks.js
Created April 19, 2017 11:31
lofi task runner
/* eslint-disable no-console, arrow-body-style, quote-props, no-param-reassign */
const chokidar = require('chokidar');
const compileCSS = require('./css');
const cp = require('child_process');
const debounce = require('lodash/debounce');
const fs = require('fs');
const path = require('path');
const Promise = require('bluebird');
function run(cmd, args = []) {
@akx
akx / arrben.js
Last active May 22, 2017 16:26
for vs foreach
/**
$ node --version
v7.10.0
$ node arrben.js
foreach 2294.22208
for 1342.5684099999999
*/
const benchmark = (name, fn, n = 100) => {
@akx
akx / webpack-proj4leaflet.js
Created May 24, 2017 08:21
webpack/es6 compatible proj4leaflet.js
// Usage: `require('./webpack-proj4leaflet');` -- the code patches itself into L.Proj, as usual.
import L from 'leaflet';
import proj4 from 'proj4';
L.Proj = {};
L.Proj._isProj4Obj = function (a) {
return (typeof a.inverse !== 'undefined' &&
typeof a.forward !== 'undefined');
// usage:
// import addProj4Leaflet from './byol-proj4leaflet';
// later ... ...
// const L = require('leaflet');
// const proj4 = require('proj4');
// addProj4Leaflet(L, proj4);
module.exports = (function (L, proj4) {
if(proj4.__esModule && proj4.default) {
proj4 = proj4.default;
@akx
akx / gist:ff2c39eb8615208a7b1f90520951c4bd
Created June 15, 2017 13:28
Dependency loops in npm
[('1615-node-2017', '1615-node-001'), ('1615-node-001', '1615-node-2017')]
[('Accessor', 'Accessor_Singleton'), ('Accessor_Singleton', 'Accessor')]
[('aglio-theme-api', 'aglio-fork'), ('aglio-fork', 'aglio-theme-api')]
[('alicemodule01', 'alicemodule01')]
[('ameya-shukla', 'ameya-shukla')]
[('animate-css-styled-components', 'animate-css-styled-components')]
[('arc-check', 'arc-object'), ('arc-object', 'arc-check')]
[('art-build-configurator', 'art-build-configurator')]
[('art-build-configurator', 'art-class-system'), ('art-class-system', 'art-build-configurator')]
[('art-build-configurator', 'art-config'), ('art-config', 'art-build-configurator')]
@akx
akx / rando.js
Created September 12, 2017 13:17
const crypto = require("crypto");
function gen(
rand = Math.random,
n = 10,
alphabet = "abcdefghijklmnopqrstuvwxyz"
) {
let p = "";
for (var i = 0; i < n; i++)
p += alphabet[Math.floor(rand() * alphabet.length)];
@akx
akx / delete_libraries.py
Created February 18, 2018 16:47
delete_libraries.py - delete node_moduleses and venvs
import os
import sys
import argparse
import shutil
import traceback
def process(path, interactive=False):
if not interactive:
print(path)
@akx
akx / dump.js
Created March 5, 2018 09:19
Dump and load local storage
function dumpLocalStorage() {
return (
Object.keys(localStorage)
.map((key) => [key, localStorage[key]])
.reduce((acc, [key, val]) => { acc[key] = val; return acc; }, {})
);
}
function loadLocalStorageDump(dump) {
if(typeof dump === 'string') dump = JSON.parse(dump);
@akx
akx / index.js
Created March 15, 2018 09:02
for loops vs. every
$ node index.js
for: 1196073 hz
every: 417669 hz
Fastest is for
$
@akx
akx / gist:cf069e214f8654931d3fda2d3ac4cbc4
Created April 3, 2018 17:06
Babel download stats, 2018-03
SELECT file.version, COUNT(*) c
FROM `the-psf.pypi.downloads201803*`
WHERE file.project = 'babel'
GROUP BY file.version
ORDER BY c DESC
---
$ tr ',' '\t' < results-20180403-200146.csv | expand
version c