Skip to content

Instantly share code, notes, and snippets.

Jason Mulligan avoidwork

Block or report user

Report or block avoidwork

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@avoidwork
avoidwork / sw.js
Last active Oct 15, 2019
Service worker template for CRUD cache invalidation
View sw.js
const name = 'mycache-1',
timeout = 18e2, // 30 min
nocache = ['/some/api'],
urls = ['/cache/me'];
self.addEventListener('activate', ev => ev.waitUntil(caches.keys().then(args => {
const x = args.filter(i => i !== name);
return x.length === 0 ? Promise.resolve() : Promise.all(x.map(i => caches.delete(i)));
})));
@avoidwork
avoidwork / steps.txt
Created May 21, 2019
Expand root partition (LVM)
View steps.txt
sudo pvresize /dev/$disk
sudo vgdisplay
sudo lvresize -L $sizeG -r /dev/$vg/$lv
sudo lvdisplay
@avoidwork
avoidwork / adobe.js
Created Apr 7, 2019
Adobe employees active on github
View adobe.js
(async function () {
const fetch = require('node-fetch'),
moment = require('moment'),
users = new Map(),
size = 100;
let i = -1,
nth = -1,
done = false;
@avoidwork
avoidwork / gist:7ea182c5fbfb014b891ad205cd580502
Created Nov 15, 2018
MongoDB flatten aggregation & update
View gist:7ea182c5fbfb014b891ad205cd580502
new_recommended = db.profiles.aggregate([{$unwind: "$recommended"}, {$group: {_id : "$_id", recommended: {$push: "$recommended"}}}]).toArray();
new_recommended.forEach(function (x) {db.profiles.update({_id: x._id}, {$set: {recommended: x.recommended}})});
@avoidwork
avoidwork / eventsource.js
Last active Nov 3, 2018
EventSource life cycle
View eventsource.js
let retry, stream;
function log (arg) {
console.log(`[${new Date().getTime()}] ${arg}`);
}
function createStream () {
if (retry !== void 0) {
clearTimeout(retry);
retry = void 0;
@avoidwork
avoidwork / index.js
Last active Oct 19, 2018
WHATWG searchParams.getAll() benchmark
View index.js
const precise = require('precise'),
{URL} = require('url'),
nth = 1e4,
limit = 80 * 1024;
let uri = 'http://something.com/?',
i = -1;
while (++i < nth) {
const x = Math.floor(Math.random() * 6) + 2;
let n = -1, k = '', v = '';
@avoidwork
avoidwork / dockerfile
Last active Aug 24, 2018
docker with node, python & compilers
View dockerfile
FROM node:10.6-alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json /usr/src/app/
RUN apk add --no-cache --virtual .gyp \
@avoidwork
avoidwork / index.js
Last active Apr 12, 2018
Azure Function node.js with pagination, sorting & hypermedia
View index.js
'use strict';
const url = require('url'),
config = require('./config.json'),
mongodb = require('mongodb'),
keysort = require('keysort');
function clone (arg) {
return JSON.parse(JSON.stringify(arg));
}
@avoidwork
avoidwork / .log
Created Oct 10, 2017
npm debug log
View .log
0 info it worked if it ends with ok
1 verbose cli [ '/Users/jamullig/.nvm/versions/node/v8.5.0/bin/node',
1 verbose cli '/Users/jamullig/.nvm/versions/node/v8.5.0/bin/npm',
1 verbose cli 'start' ]
2 info using npm@5.3.0
3 info using node@v8.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle bench-lru@1.1.0~prestart: bench-lru@1.1.0
6 info lifecycle bench-lru@1.1.0~start: bench-lru@1.1.0
7 verbose lifecycle bench-lru@1.1.0~start: unsafe-perm in lifecycle true
@avoidwork
avoidwork / .json
Created Oct 10, 2017
brench-lru package-lock.json for issue #13
View .json
{
"name": "bench-lru",
"version": "1.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"abstract-object": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/abstract-object/-/abstract-object-2.1.9.tgz",
"integrity": "sha1-+p/IiI7MzELD2mxPYbnOqhoaGhQ=",
You can’t perform that action at this time.