Skip to content

Instantly share code, notes, and snippets.

View paolobueno's full-sized avatar

Paolo Bueno paolobueno

View GitHub Profile
@paolobueno
paolobueno / .gitignore
Last active December 1, 2015 13:26 — forked from chriskjaer/gulpfile.js
Gulp recipe: Jade, Sass, Livereload and static server
node_modules
dist/
@paolobueno
paolobueno / promisify.js
Created April 6, 2016 11:23
Simple promisify
/**
* Simple promisifier for a function that expects a node-like callback
* @param {Function} fn Function to promisify, should expect a node-like callback as the last parameter
* @return {Function} the promisified wrapped version of the function
*/
module.exports = function promisify (fn) {
return function () {
var paramsArr = Array.prototype.slice.call(arguments);
return new Promise(function (resolve, reject) {
@paolobueno
paolobueno / error-handler.js
Last active February 2, 2017 18:49
Does express global error handler works with `throw`?
var express = require('express');
var Promise = require('bluebird');
var app = express();
var router = express.Router();
router.get('/error', function(req, res, next) {
return new Promise(function() {
throw new Error('boom');
}).catch(next);
});
@paolobueno
paolobueno / workflow.js
Created September 4, 2017 16:28 — forked from wtrocki/workflow.js
Workflow mobile data structure
var workorder = {
"_id": "59aafac97037bfbab2a8f9a1",
"id": "SJ8b3Mr8g",
"assignee": "rkX1fdSH",
"title": "Accident No. 3019",
"status": "New",
"stepHistory": [
{
id: 'someid',
user: 'trever'
@paolobueno
paolobueno / dockerc.xml
Last active December 11, 2017 15:16
mcp troubleshooting
<?xml version="1.0" encoding="utf-8"?>
<zone>
<source address="172.17.0.0/16"/>
<port port="8443" protocol="tcp"/>
<port port="53" protocol="udp"/>
<port port="8053" protocol="udp"/>
<port port="443" protocol="tcp"/>
</zone>
@paolobueno
paolobueno / typingTest.ts
Created January 18, 2018 18:32
Strong strings
class ServiceModule {}
class SyncService extends ServiceModule {}
class KeycloakService extends ServiceModule {}
type ServiceModuleConstructor<T extends ServiceModule> = new() => T;
class ServiceModuleRegistry {
private serviceTypeMap: {
[key: string]: ServiceModuleConstructor<ServiceModule>
@paolobueno
paolobueno / overloading.ts
Created February 20, 2018 16:36
Config overload
export interface IKeycloakConfig {}
export interface IMetricsConfig {}
export class Config {
private serviceConfig: any[] = [];
/**
* @param config - any type of configuration that will be send from server.
* It's not possible easy/worth to wrap that to types. Even native implementations do not do that.
@paolobueno
paolobueno / benchmarks.sql
Created March 14, 2018 12:40
app metrics benchmarks
/*
Tested with data generated by
autocannon -a 150000 -m POST -I -b '{"clientId":"[<id>]","data":{"app":{"appId":"com.example.someApp","sdkVersion":"2.4.6","appVersion":"256"},"device":{"platform":"android","platformVersion":"27"}}}' http://localhost:3000/metrics
Thus creating 150k records.
This uses generated clientIds and the rest of the data is constant, thus it doesn't match very well the expected cardinality,
I'd like to redo these tests with better random data.
For example we wouldn't have unique clientIds per record, and have some variance in device platform, and some less in app info, and also a much bigger spread in event_times.
@paolobueno
paolobueno / permissions.sh
Created March 15, 2018 17:23
apb permissions
oc login -u system:admin
oc adm policy add-cluster-role-to-user access-asb-role developer
oc adm policy add-cluster-role-to-user cluster-admin developer
@paolobueno
paolobueno / compose.js
Last active September 25, 2018 12:31
Simple variadic compose
const apply = (x, fn) => fn(x);
const c = (...fns) => {
[first, ...rest] = fns.reverse();
return x => rest.reduce(apply, first(x));
}
const add = x => y => x + y;
c(add(1), add(4))(3);