Skip to content

Instantly share code, notes, and snippets.

View mcollina's full-sized avatar

Matteo Collina mcollina

View GitHub Profile
@mcollina
mcollina / principles.md
Last active May 18, 2023 18:27
Matteo's Technical principles

Matteo Technical Principles

1. Conway’s Law is paramount.

Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.

In order to design a piece of software we need to “design” the team that is going to produce it.

2. Developer Experience is key to productivity

@mcollina
mcollina / exhaust.mjs
Last active May 19, 2021 21:48
merge ensuring that all generators are fully consumed
import { setTimeout } from 'timers/promises'
import { strictEqual } from 'assert'
let called = 0
async function * merge (a, b) {
try {
yield *a
yield *b
} finally {
@mcollina
mcollina / tap-15.sh
Last active April 6, 2021 08:24
Remove all tap@15 deprecations
#!/bin/sh
find ./test -regex '.*js' | xargs sed -I '' 's/tearDown/teardown/g'
find ./test -regex '.*js' | xargs sed -I '' 's/strictEqual/equal/g'
find ./test -regex '.*js' | xargs sed -I '' 's/deepEqual/same/g'
find ./test -regex '.*js' | xargs sed -I '' 's/false(/notOk(/g'
find ./test -regex '.*js' | xargs sed -I '' 's/notStrictEqual/not/g'
find ./test -regex '.*js' | xargs sed -I '' 's/similar/match/g'
find ./test -regex '.*js' | xargs sed -I '' 's/strictDeepEqual/strictSame/g'
find ./test -regex '.*js' | xargs sed -I '' 's/is(/equal(/g'
find ./test -regex '.*js' | xargs sed -I '' 's/throw(/throws(/g'
'use strict'
const {
graphql,
parse,
buildSchema,
extendSchema,
buildASTSchema
} = require('graphql')
exports.notification = (req, res, next) => {
const notificationPayload = {
notification: {
title: 'Blogial new post',
body: req.body.title,
icon: 'assets/icons/icon-512x512.png'
}
};
Subscription.find()
.then(subscriptions => {
'use strict'
const { Readable, finished } = require('stream')
const { promisify } = require(util)
async function run (origin, dest) {
try {
const write = buildWrite(dest)
// This is an async iterator
for await (let chunk of origin) {
const http2 = require('http2');
const options = {
key: getKeySomehow(),
cert: getCertSomehow()
};
// https is necessary otherwise browsers will not
// be able to connect
const server = http2.createSecureServer(options, (req, res) => {
res.end('Hello World!');
@mcollina
mcollina / summit.md
Last active February 26, 2018 14:04
Collaborato Summit - May 31st - June 1st 2018, Berlin

Collab Summit Berlin 2018

We are back with the date for the Node.js Collaborator Summit in Berlin next to JSConf.Eu (which is on June 2-3, 2018). This is a live issue that will be constantly updated to match the proposed agenda.

Collaborator Summit Day One: May 31st, 2018

AWS Berlin address TBD 10am-6pm

test('Register an hook after a plugin', t => {
t.plan(6)
const fastify = Fastify()
fastify.register(fp(function (instance, opts, next) {
instance.addHook('preHandler', function (req, reply, next) {
t.ok('called')
next()
})
#! /bin/bash
set -x
set -e
curl -L https://github.com/nodejs/node/pull/$1.patch | git am --whitespace=fix
get-metadata $1 -f msg.txt
echo -e "$(git show -s --format=%B)\n\n$(cat msg.txt)" > msg.txt
git commit --amend -F msg.txt
git show -s --format=%B