Skip to content

Instantly share code, notes, and snippets.


David Castellani davidcastellani

View GitHub Profile
#Bail if borg is already running, maybe previous run didn't finish
if pidof -x borg >/dev/null; then
echo "Backup already running"
# Setting this, so the repo does not need to be given on the commandline:
export BORG_REPO=/mnt/backup/prox01/main
davidcastellani / migrate
Created January 29, 2018 21:23
Move Proxmox Container to Different Storage (Updated for LXC)
View migrate
# Filename : migrate
# Description : Migrate Proxmox OpenVZ container from one storage to another
# Author : James Coyle
# URL:
# Version:
# -Date -Author -Description
# 20-11-2013 James Coyle Initial
# 13-12-2017 James Coyle Changes for LXC
davidcastellani /
Created May 17, 2016 13:26 — forked from lyoshenka/
Check that MySQL slave is running and no errors are present. Optionally send an email if errors are detected.
set -euo pipefail
EMAIL_ADDR="" # email this address if errors detected
MAX_SECONDS_BEHIND=5 # max seconds that slave can be behind master
davidcastellani /
Created May 17, 2016 13:26 — forked from lyoshenka/
Bash Random Password Generator
head -n100 /dev/urandom | strings | egrep -o '([a-zA-Z0-9#%&^])' | awk '{ORS=""; print $1}' | head -c 35; echo
davidcastellani / latency.txt
Created May 17, 2016 13:25 — forked from lyoshenka/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
davidcastellani / expert_level_php.xml
Last active September 2, 2015 19:12 — forked from Swader/expert_level_php.xml
Expert level coding standards inspection for PHP in PHPStorm
View expert_level_php.xml
<?xml version="1.0" encoding="UTF-8"?>
<inspections version="1.0" is_locked="false">
<option name="myName" value="Expert Level PHP" />
<option name="myLocal" value="false" />
<inspection_tool class="BadExpressionStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CallerJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CommaExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ConstantConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ConstantIfStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ContinueOrBreakFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />

Keybase proof

I hereby claim:

  • I am davidcastellani on github.
  • I am davidcastellani ( on keybase.
  • I have a public key whose fingerprint is C541 19B9 8D12 0A13 A55B 8642 A0DE 462D 98C9 E614

To claim this, I am signing this object: