Skip to content

Instantly share code, notes, and snippets.

View seriousme's full-sized avatar

Hans Klunder seriousme

View GitHub Profile
@seriousme
seriousme / test-fastify.js
Created September 19, 2024 17:21
Reproduction of 'FST_ERR_LOG_INVALID_LOGGER_CONFIG' issue in [email protected]
import { strict as assert } from "node:assert/strict";
// just test the basics to aid debugging
import { test } from "node:test";
import Fastify from "fastify";
const opts = {
schema: {
querystring: {
type: "object",
properties: {
class AsyncQueue {
#queue = [];
#maxQueueLength = Infinity;
#nextResolve = () => {};
#hasNext = false;
constructor(maxQueueLength) {
if (maxQueueLength) {
this.#maxQueueLength = maxQueueLength;
}
@seriousme
seriousme / petstore-v3.1.json
Created April 28, 2021 07:11
OpenApi v3.1 PetStore example
{
"openapi": "3.1.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
@seriousme
seriousme / transform.js
Last active August 19, 2020 18:16
Transforming an OpenAPi v3 spec
// small transformation utility to modify an openApi spec
// tested against: https://github.com/ringcentral/ringcentral-api-specifications/blob/master/ringcentral.spec.2019110220191017-1140.openapi3.yaml
const yaml = require('js-yaml');
const fs = require('fs');
const condition = 'x-auth-required';
const filename = 'ringcentral.spec.openapi3.yaml';
// Transformation function
function transform(spec) {
@seriousme
seriousme / chrome.log
Created April 9, 2016 13:13
Tracing MQTT.js
Parser.prototype.parse 6377
BufferList.prototype.append 6200
Buffer.isBuffer 225
Parser.prototype._parseHeader 6387
BufferList.prototype[m] 6325
BufferList.prototype.slice 6228
BufferList.prototype.copy 6231
BufferList.prototype._offset 6189
Buffer.prototype.slice 673
Buffer._augment 1186
{
"swagger": "2.0",
"info": {
"description": "Testlab user account api.",
"version": "1.0.0",
"title": "Testlab user account",
"termsOfService": "http://labmgmt.testlab.local/terms/",
"contact": {
"name": "Testlab Team",
"email": "[email protected]"
@seriousme
seriousme / docker-monitor.js
Last active August 5, 2024 06:33
Simple docker monitor in node.js
// simple script to monitor a docker engine
// 14 March 2016
// https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/#monitor-docker-s-events
const https = require('https');
const fs = require('fs');
// for now we use a dummy registry, but we could link this to consul, etcd etc..
var registry={};
// setup TLS config to be able to talk to docker, when run in a container we
@seriousme
seriousme / Loki2RethinkDB-evented.js
Created April 12, 2015 08:11
Streaming loki changes into rethinkdb
var rdb = require('rethinkdb'),
loki = require('lokijs'),
db,
connection;
function forwardInsert(db, connection, table, record, callback) {
var cb = callback || function (err, obj) {
if (err) {
throw err;
}
var defaultPersistence={ 'NODEJS': 'fs', 'BROWSER': 'localStorage', 'CORDOVA': null };
if (this.persistenceMethod == null){
this.persistenceMethod = defaultPersistence[this.ENV];
if (! this.persistenceMethod){
throw Error('unknown environment')
}
}
if (this.persistenceMethod === 'adapter') {
@seriousme
seriousme / loki-test.js
Created March 12, 2015 18:59
loki crypted file adapter
var cryptedFileAdapter = require('./lokiCryptedFileAdapter');
cryptedFileAdapter.setSecret('mySecret');
var loki=require('lokijs');
var db = new loki('loki.json.crypted',{ adapter: cryptedFileAdapter });
db.loadDatabase({},function(){
var children = db.addCollection('children');
children.insert({name:'Bleep', legs: 2});
db.save();