Skip to content

Instantly share code, notes, and snippets.

View voxpelli's full-sized avatar

Pelle Wessman voxpelli

View GitHub Profile
@voxpelli
voxpelli / bunyan-setup.js
Created August 2, 2017 09:30
Part of custom Bunyan setup with Logstash output, as used by HD-Sydsvenskan
const bunyan = require('bunyan');
const bunyanExpressSerializer = require('bunyan-express-serializer');
const LogstashStream = require('./logstash-stream');
const streams = [
{
level: 'trace',
type: 'raw',
stream: new LogstashStream(outStream)

Test case for duplicate downloads of Link Preloads

  1. Download package.json and single-preload.js and put into same folder
  2. Run npm install
  3. Run node single-preload.js
  4. Visit http://127.0.0.1:4000/ using Safari Technology Preview 24 with the Link Preload experimental feature activated
  5. Check the Network tab of the web development tools. See two style.css that's loaded
@voxpelli
voxpelli / main.js
Last active April 19, 2022 12:43
A recursive Promise.all() that works on objects
const zipObject = function (keys, values) {
const result = {};
keys.forEach((key, i) => {
result[key] = values[i];
});
return result;
};
@voxpelli
voxpelli / keybase.md
Created September 2, 2016 08:12
keybase.md

Keybase proof

I hereby claim:

  • I am voxpelli on github.
  • I am voxpelli (https://keybase.io/voxpelli) on keybase.
  • I have a public key whose fingerprint is 65D3 06C1 79C7 5F64 0B4F 84C2 A62A 96DF E7A1 4F5A

To claim this, I am signing this object:

const stream = {
level: 'warn',
type: 'raw',
stream: { write: (obj) => {
console.log(
[
bunyan.nameFromLevel[obj.level],
obj.msg,
obj.err ? bunyan.stdSerializers.err(obj.err).stack : false
]
@voxpelli
voxpelli / log-chai-error-with-diff.js
Created July 11, 2016 10:12
This small snippet leverages Mocha's reporter to do proper diffs of Chai assertion errors so that one can log them oneself as well
const mochaList = require('mocha').reporters.Base.list;
const mochaErrorLog = function (err, title) {
mochaList([{
err,
fullTitle: () => title || 'Untitled'
}]);
};
@voxpelli
voxpelli / gist:e08600ee1bd1ca254a46ff437e672200
Created May 6, 2016 11:23
git alias to notify on git push fail (works on OS X)
git config --global alias.pushh '!git push $@ || terminal-notifier -message "Push failed" -title "git"'
var validateInstalledDependencies = function () {
var readJson = require('read-package-json');
var readInstalled = require('read-installed');
var semver = require('semver');
var packagePromise = new Promise(function (resolve, reject) {
readJson('package.json', function (err, data) {
if (err) { return reject(err); }
resolve(data);
});
@voxpelli
voxpelli / README.md
Last active July 19, 2016 18:36
How to get references to all PR:s on a "git fetch origin" – forgot where I found this, but rediscovered the setup in one of my local repos

In the .git/config file add the fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to the remote you want to fetch references to PR:s from.

@voxpelli
voxpelli / README.md
Last active August 29, 2015 14:27
Private Messaging With From: Sequence diagram