Skip to content

Instantly share code, notes, and snippets.

View bcicen's full-sized avatar

bradley bcicen

View GitHub Profile
@drsnyder
drsnyder / urandom-reads.py
Last active August 11, 2021 10:44
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
#
# urandom-reads.py infile threads
# Examples:
# time python2.6 urandom-reads.py /tmp/urandom
# time python2.6 urandom-reads.py /dev/urandom
#
# R to generate a plot of the read time distribution at each level of concurrency
# rdt = read.csv("output.csv", header=F)
@jordansissel
jordansissel / foo.md
Last active February 6, 2021 22:08
logstash message format

logstash json format

{
  "message"    => "hello world",
  "@version"   => "1",
  "@timestamp" => "2014-04-22T23:03:14.111Z",
  "type"       => "stdin",
  "host"       => "hello.local"
}
@sivel
sivel / wp-mysql-test.php
Created August 5, 2009 20:04
Database connection test script for WordPress
<?php
/**
* Database connection test script for WordPress
*
* Parses the wp-config.php file for DB connection information and tests
* a mysql connection to the DB server and selection of the database.
* Errors will be reported. Attempts will be made to repair table errors.
*
* Place this file in the same directory as wp-config.php
*

Displaying images in the terminal with tput and echo

output

Requires ImageMagick, easily available from your favorite package manager. Tested on Linux and OSX
convert image.png -resize 40 txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/([0-9]+,[0-9]+,[0-9]+),[0-9]+/\1/g;s/255/254/g;/mage/d'|awk '{print $1,$2}'|sed -E 's/^0,[0-9]+ /print "echo;tput setaf "\;/;s/^[0-9]+,[0-9]+ /print "tput setaf ";/;s/(.+),(.+),(.+)/\1\/42.5*36+\2\/42.5*6+\3\/42.5+16/'|bc|sed 's/$/;echo -n "  ";/'|tr '\n' ' '|sed 's/^/tput rev;/;s/; /;/g;s/$/tput sgr0;echo/'|bash
@lost-theory
lost-theory / netstat-2015.md
Last active September 10, 2018 11:25
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])
@mbijon
mbijon / syslog-ng.conf
Created November 26, 2013 19:37 — forked from caquino/syslog-ng.conf
Syslog nginx without $ or patching, http://syshero.org/post/68174083489/nginx-syslog-ing-without-breaking-the-bank-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…
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); };

#cargo, docker hub without docker, how to

18 Jan 2015

###Background

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 !

# 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