Skip to content

Instantly share code, notes, and snippets.

Avatar

Marc Bachmann marcbachmann

View GitHub Profile
@marcbachmann
marcbachmann / ndjson-iterator.js
Created Sep 30, 2020
Newline Delimited JSON Stream Iterator for json streams in the browser
View ndjson-iterator.js
const response = await fetch(`http://localhost:8080/stream`, {
method: 'get',
headers: {
Authorization: `Bearer SomeToken`
}
})
for await (const value of ndJsonIterator(response.body)) {
console.log(value)
}
@marcbachmann
marcbachmann / etc_docker_daemon.json
Created Jan 29, 2018
docker container logs using rsyslog & journald
View etc_docker_daemon.json
{ "log-driver": "journald", "log-opts": {"tag": "{{.Name}}/{{.ID}}"}}
@marcbachmann
marcbachmann / Dockerfile
Created Nov 21, 2017
syslog-ng Dockerfile
View Dockerfile
FROM multiarch/alpine:x86_64-v3.6 as syslog-ng
ENV VERSION=3.12.1
RUN apk --no-cache add ca-certificates glib pcre eventlog libressl json-c && \
apk add --no-cache --virtual .build-deps alpine-sdk wget build-base glib-static glib-dev eventlog-dev pcre-dev libressl-dev python2-dev json-c-dev && \
wget -O "/tmp/syslog-ng-$VERSION.tar.gz" "https://github.com/balabit/syslog-ng/releases/download/syslog-ng-$VERSION/syslog-ng-$VERSION.tar.gz" && \
cd /tmp && \
tar zxfv "syslog-ng-$VERSION.tar.gz" && \
cd "syslog-ng-$VERSION"
View syslog-ng.conf
@version: 3.12
options {
chain_hostnames(0);
time_reopen(10);
time_reap(360);
log_fifo_size(2048);
create_dirs(yes);
group(adm);
perm(0640);
View fluent-bit-containers.conf
[SERVICE]
Flush 5
Daemon Off
Log_Level info
Parsers_File /etc/fluent-bit/parsers.conf
[INPUT]
Name Tail
Path /mnt/data/docker/containers/*/*.log
Path_Key file
@marcbachmann
marcbachmann / Travis Docker Scripts.md
Last active Sep 21, 2020
Several bash scripts for TravisCI. Scripts to update docker, run a http proxy, and pull most recent docker image from docker hub
View Travis Docker Scripts.md

Travis Docker Scripts

Usage

Define the GIST url and pipe some script to bash/sh

GIST=https://gist.githubusercontent.com/marcbachmann/16574ba8c614bb3b78614a351f324b86/raw/a7e17acc57938a047c093f560858e3b0a8e2c741
curl -s $GIST/script-name | bash
View -
var async = require('async')
var ms = require('ms')
var _ = require('lodash')
var config = require('./config')
var Docker = require('dockerode')
var docker = new Docker(config.docker)
var api
api =
module.exports = {
@marcbachmann
marcbachmann / change-semantic-release-props.js
Created Dec 15, 2016
Semantic release - change release & publishConfig in package.json
View change-semantic-release-props.js
var fs = require('fs')
var jp = require('jsonpointer')
var tag = process.env.TAG
var branch = process.env.BRANCH
if (!tag || !branch) {
console.error([
'Error: BRANCH and TAG environment variables are required.',
@marcbachmann
marcbachmann / README.md
Last active Dec 10, 2016
Bench function vs bind vs new Object
View README.md

Node 6.9.1

NANOBENCH version 1

# benchFunction
  end ~220 ms (0 s + 219586469 ns)
# benchBind
  end ~3.19 s (3 s + 186017098 ns)
# benchObject
  end ~90 ms (0 s + 89620728 ns)
@marcbachmann
marcbachmann / in_memory_repository.js
Last active Dec 5, 2016
In memory eventsourcing repository
View in_memory_repository.js
var util = require('util')
var EventEmitter = require('events').EventEmitter
var _ = require('lodash')
var Aggregate = require('eventsourced-object')
function InMemoryRepository (Model) {
this.eventCount = 0
this._Model = Model
}