Skip to content

Instantly share code, notes, and snippets.

Avatar

Bertrand Tornil bobuss

View GitHub Profile
@bobuss
bobuss / logrotate.cron
Last active Aug 29, 2015
logrotate template
View logrotate.cron
#!/bin/sh
# Delete log files older than {{ daysdelete }} days
nice -n 19 find {{ logdirectory }} -type f -name "*.bz2" -mtime +{{ daysdelete }} -exec rm '{}' \; >/dev/null 2>&1
# Compress log files older than {{ dayscompress }} days
ionice -c3 nice -n 19 find {{ logdirectory }} -type f ! -path "*.bz2" ! -path "*.log" ! -path "*.gz" -mtime +{{ dayscompress }} -exec bzip2 '{}' \; >/dev/null 2>&1
# Reload rsyslog
/bin/kill -HUP $(cat /var/run/rsyslogd.pid)
View gist:988aaca32f5fbe6e73a9

Install a raspbian image on a sd-card, under Max OSX

Fast and clean !

$ df -h
Filesystem                                          Size   Used  Avail Capacity   iused     ifree %iused  Mounted on
/dev/disk1                                         465Gi  188Gi  276Gi    41%  49449884  72346210   41%   /
...
/dev/disk2s1                                        56Mi   14Mi   42Mi    26%       512         0  100%   /Volumes/boot
@bobuss
bobuss / index.html
Last active Aug 29, 2015
index.html start file
View index.html
<!DOCTYPE html>
<!-- Based on HTML5 Bones | http://html5bones.com -->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Title</title>
<meta name="description" content="">
@bobuss
bobuss / README.md
Last active May 3, 2018
Setup a Redis Cluster using docker-machine
View README.md
@bobuss
bobuss / change_git_author
Created Nov 6, 2014
Change the git commits author
View change_git_author
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
View liste-de-departements-limitrophes-francais.txt
01:38,39,69,71,73,74
02:08,51,59,60,77,80
03:18,23,42,58,63,71
04:05,06,26,83,84
05:04,26,38,73
06:04,83
07:26,30,38,42,43,48,84
08:02,51,55
09:11,31,66
10:21,51,52,77,89
@bobuss
bobuss / logging.py
Created Mar 5, 2014
Send locals to your sentry server while an exception occurs
View logging.py
from __future__ import absolute_import
import pprint
from raven.handlers.logging import SentryHandler
class VerboseSentryHandler(SentryHandler, object):
"""
Subclass the SentryHandler in order to add the locals to the record
Inspired by The Verbose exception Formatter
From Bitly blog : http://word.bitly.com/post/69080588278/logging-locals
@bobuss
bobuss / Makefile
Created Sep 13, 2013
Makefile for python project continuous integration
View Makefile
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 / Calisthenics.md
Last active Oct 3, 2020
The 9 Rules of Object Calisthenics
View Calisthenics.md

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 / Numbers.txt
Last active Dec 22, 2015
Numbers Everyone Should Know
View Numbers.txt
- 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
You can’t perform that action at this time.