Skip to content

Instantly share code, notes, and snippets.


bradley bcicen

View GitHub Profile
randallmlough / translate.go
Last active Dec 12, 2022 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures – []map[string]interface{} support
View translate.go
// Traverses an arbitrary struct and translates all stings it encounters
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
// The MIT License (MIT)
// Copyright (c) 2014 Heye Vöcking

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional


dannguyen /
Last active Jun 13, 2022
A command-line function that runs a SQLite query and gets a Markdown-ready table; See console demo at
### sqlmd
# Bash function for outputting SQLite results in Markdown-friendly table
### Dependency:
# csvlook can be found here:
# $ sqlmd "SELECT name, age FROM people;" optional_db_name_argument.sqlite

#cargo, docker hub without docker, how to

18 Jan 2015


I have been using linux containers for almost 2 years now. It started during an internship at Applidget, a startup in Paris. My job was to integrate linux containers technology in their private PaaS. At this time, there where no doubt, the technology to use was LXC. One week or so after I started digging into LXC, one of my co-worker talked to me about this new thing called docker. He told me "isn't it what you are supposed to do during your internship ?". And it was kind of it.

At this time I already highlighted a big challenge of containers in PaaS: creation time. Waiting for bundle install to complete is already long enough to have to wait for another 40 secondes to create a container :). Docker landed just in time !

View gist:55bb5b6a4b7457bef38d
# this forces dpkg not to call sync() after package extraction and speeds up install
RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup
# we don't need and apt cache in a container
RUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache
jdoconnor / gist:32ef0314cecb80157c4e
Created Sep 26, 2014
Update mtimes based off commit time
View gist:32ef0314cecb80157c4e
#!/bin/bash -e
# based on
# Helper script to update the Last modified timestamp of files in a Git SCM
# Projects working Copy
# When you clone a Git repository, it sets the timestamp of all the files to the
# time when you cloned the repository.
# This becomes a problem when you want the cloned repository, which is part of a
drsnyder /
Last active Aug 11, 2021
Demonstrate the contention on /dev/urandom with N threads.
# Create a user land file for testing.
# dd if=/dev/urandom of=/tmp/urandom bs=1M count=10
# infile threads
# Examples:
# time python2.6 /tmp/urandom
# time python2.6 /dev/urandom
# R to generate a plot of the read time distribution at each level of concurrency
# rdt = read.csv("output.csv", header=F)
# This gist is compatible with Ansible 1.x .
# For Ansible 2.x , please check out:
# -
# -
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
mbijon / syslog-ng.conf
Created Nov 26, 2013 — forked from caquino/syslog-ng.conf
Syslog nginx without $ or patching, (1) directory/fifo structure: mkdir -p /srv/logs/ mkfifo /srv/logs/access.log mkfifo /srv/logs/error.log (2) nginx conf: error_log /srv/logs/error.log; access_log /srv/logs/access.log; (3) remember to start syslog-ng bef…
View syslog-ng.conf
source s_nginx_20 { pipe("/srv/logs/access.log" program_override("nginx-access-log")); };
source s_nginx_21 { pipe("/srv/logs/error.log" program_override("nginx-error-log")); };
filter f_nginx_20 { match("nginx-access-log" value("PROGRAM")); };
filter f_nginx_21 { match("nginx-error-log" value("PROGRAM")); };
destination d_remote { tcp("central.syslog", port(514)); };
log { source(s_nginx_20); filter(f_nginx_20); destination(d_messages); };
log { source(s_nginx_21); filter(f_nginx_21); destination(d_messages); };
lost-theory /
Last active Sep 10, 2018
netstat on all machines -> python -> graphviz -> png
$ knife ssh -m "...every host in the network..." "sudo netstat -nutap" -a hostname > meganetstat.txt
$ python
>>> from collections import Counter as C
>>> HS = "...every host in the network...".split()
>>> ip = lambda s: s.split(":")[0]
>>> xs = [map(ip, [x[0], x[4], x[5]]) for x in [x.strip().split() for x in open("meganetstat.txt").readlines() if "tcp" in x] if len(x)>=6]
>>> ipmap = [(h, C([x[1] for x in xs if x[0] == h])) for h in HS]
>>> ipmapx = dict([(sorted([(x,y) for (x,y) in ip[1].items() if x.startswith("10.")], key=lambda t: -t[1])[0][0], ip[0]) for ip in ipmap])
>>> sorted(C(map(ipmapx.get, [x[2] for x in xs if x[2].startswith("10.")])).items(), key=lambda t: t[1])