Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am bartkrol on github.
  • I am bartkrol (https://keybase.io/bartkrol) on keybase.
  • I have a public key ASBJBRcjH_dGa-u9xmP1ykKckI_wI0zgow1GC2jZ_Nk5IAo

To claim this, I am signing this object:

@BartKrol
BartKrol / superexpress.js
Last active April 24, 2017 10:38
PoC for testing lib for express
const request = require('superexpress')
const { getResources } = require('./controllers/resourses')
const expectedData = [...]
// Testing code with Chai+Mocha
describe('My test', () => {
it('should return resources' () => {
return request(getResources)
.query({ name: 'some-name', conditon: 'some-condition' })
@BartKrol
BartKrol / loader.js
Created October 20, 2016 11:44
Which one is better
function interceptLoadFunctions(name, loader) {
return Object.assign({}, loader, {
load(id) {
return loader.load(id).catch(itemErrorHandler(name, id))
},
loadMany(ids, ...args) {
return loader.loadMany(ids).catch(multipleItemsErrorHandler(name, ids))
}
})
}
@BartKrol
BartKrol / dataloader.spec.js
Last active September 8, 2016 08:17
DataLoader fails promise when Error is returned
import { expect } from 'chai'
import DataLoader from 'dataloader'
import sinon from 'sinon'
function createByIdLoader(loadFunc) {
return new DataLoader(
ids => Promise.all(
ids.map(loadFunc)
.map(promise => promise.catch(err => new Error(err)))
),
@BartKrol
BartKrol / Popover.jsx
Last active August 22, 2016 11:59
Popover timeout clearing
componentWillReceiveProps(nextProps) {
if (nextProps.open !== this.state.open) {
// (...)
} else {
if (nextProps.animated) {
if (this.timeout !== null) return; // Return if still closing
this.setState({closing: true});
// (...)
componentWillUnmount() {
@BartKrol
BartKrol / haproxy.cfg
Created February 2, 2016 11:34
HAProxy Websockets config
global
maxconn 4096
defaults
mode http
balance roundrobin
option redispatch
option forwardfor
timeout connect 5s
@BartKrol
BartKrol / haproxy.cfg
Last active February 9, 2016 11:05
HAProxy Stats
frontend http-in
bind *:8000
(...)
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /haproxy?stats
stats auth Username:Password