Skip to content

Instantly share code, notes, and snippets.

@iamjochem
iamjochem / index.js
Last active November 18, 2019 15:16 — forked from t638403/request_with_hmac_example.js
request with hmac example
/***********************************************************************************************************************
* MAKE REQUEST WITH HMAC TO API
**********************************************************************************************************************/
const fs = require('fs');
const http = require('https');
const Hmmac = require('hmmac');
const USER = process.env.HMAC_USER || '<username>';
const SECRET = process.env.HMAC_SECRET || '<secret>';
const SIGNED_HEADERS = process.env.HMAC_SIGNED_HEADERS || 'accept,date,host';
@iamjochem
iamjochem / a.json
Last active October 13, 2017 09:49
[Nodejs] json-schema-ref-parser loading bug ...
{ "oneOf" : [
{ "type" : "null" },
{ "type" : "string" },
{ "type" : "array", "items": { "type" : "string" } }
] }
@iamjochem
iamjochem / bunyanAMQStreamFactory.js
Created September 16, 2017 15:47
[NodeJS:bunyan,rabbitmq] a custom bunyan stream for publishing logs messages to amq/rabbitmq
// Bunyan AMQP Stream Transport for ES6
'use strict';
// 3rd party deps
const AMQP = require('amqplib/callback_api');
const stringify = require('json-stringify-safe');
const mydebug = require('debug')('bunyan:amq');
// our deps
const genTopic = require('./gentopic'); // used to generate a RabbitMQ topic/routing-key
@iamjochem
iamjochem / bunyanDebugRawStreamFactory.js
Last active September 16, 2017 15:03
[NodeJS:bunyan,debug] using debug module to output bunyan logs & avoiding duplicate error output
// core deps
const EOL = require('os').EOL;
// 3rd party deps
const debug = require('debug');
const bunyan = require('bunyan');
const colors = require('colors/safe');
const lrucache = require('lru-cache');
const padEnd = require('lodash/padEnd');
@iamjochem
iamjochem / gist:4611869
Created January 23, 2013 19:24
PHP implementation for the answer to the question posed here: http://news.ycombinator.com/item?id=5103163
<?php
function pascal($depth)
{
if (!is_int($depth) || $depth < 1)
return array();
if ($depth === 1)
return array(1);