Skip to content

Instantly share code, notes, and snippets.

@bobuss
bobuss / Calisthenics.md
Last active March 31, 2024 09:41
The 9 Rules of Object Calisthenics

Object Calisthenics outlines 9 basic rules to apply when performing the exercise:

  • One level of indentation per method.
  • Don't use the ELSE keyword.
  • Wrap all primitives and Strings in classes.
  • First class collections.
  • One dot per line.
  • Don't abbreviate.
  • Keep all classes less than 50 lines.
  • No classes with more than two instance variables.
@bobuss
bobuss / docker-compose.yml
Created October 14, 2023 00:20 — forked from gaieges/docker-compose.yml
Homeassistant with traefik 2.2 for TLS in docker-compose in network_mode: host
version: '2.1'
services:
homeassistant:
restart: always
image: homeassistant/raspberrypi3-homeassistant
expose:
- 8123
ports:
- "8123:8123"
@bobuss
bobuss / gist:6515517
Last active October 13, 2023 06:12
Tuning the Linux Kernel for many tcp connections

(from http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1)

Save yourself some time and tune the kernel tcp settings before testing with lots of connections, or your test will fail and you’ll see lots of Out of socket memory messages (and if you are masquerading, nf_conntrack: table full, dropping packet.)

Here are the sysctl settings I ended up with - YMMV, but these will probably do:

$ cat /etc/sysctl.conf
# General gigabit tuning:
net.core.rmem_max = 16777216
@bobuss
bobuss / Makefile
Created September 13, 2013 13:19
Makefile for python project continuous integration
ENV=env
SRC_CORE=src
CLOC=$(shell which cloc)
test-all: clean pep8 cloc init-coverage test-unit test-functionnal test-integration report-coverage flake8 lint clone
pep8:
$(ENV)/bin/pep8 --max-line-length=99 $(SRC_CORE) > pep8.log || :
@bobuss
bobuss / README.md
Last active May 3, 2018 07:27
Setup a Redis Cluster using docker-machine
@bobuss
bobuss / Numbers.txt
Last active December 22, 2015 18:49
Numbers Everyone Should Know
- L1 cache reference 0.5 ns
- Branch mispredict 5 ns
- L2 cache reference 7 ns
- Mutex lock/unlock 25 ns
- Main memory reference 100 ns
- Compress 1K bytes with Zippy 3,000 ns
- Send 2K bytes over 1 Gbps network 20,000 ns
- Read 1 MB sequentially from memory 250,000 ns
- Round trip within same datacenter 500,000 ns
- Disk seek 10,000,000 ns
@bobuss
bobuss / .gitignore
Last active December 13, 2015 22:49
Stamina recovery mecanism inside Redis TTLs
env
@bobuss
bobuss / Makefile
Created November 5, 2012 15:37
Make jshint to work with jenkins
SRC=src
$(JSHINT):
npm install jshint
JS_FILES=$(shell find $(SRC) -type f -name '*.js')
jslint: $(JSHINT)
-$(JSHINT) --jslint-reporter --config config/jshint.json > jshint.xml $(JS_FILES) || :
sed -E 's?<file name="(.*)\?">?<file name="'`pwd`'/\1">?' jshint.xml > jshint-proper.xml
@bobuss
bobuss / sitemap.py
Created July 18, 2012 13:16
Sitemap generator in python with a mustache template
import sys
import codecs
import pystache
import os
import fnmatch
import string
import datetime
webroot = 'http://www.example.com/
path = '/var/www/'
@bobuss
bobuss / commits-by-hour
Created July 2, 2012 14:47
Git commits funstats
#!/usr/bin/env bash
for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23; do echo $( echo -e "$i\t"; git shortlog -n --format='%ad %s' | grep " $i:" | wc -l); done