Skip to content

Instantly share code, notes, and snippets.

View bwesterb's full-sized avatar
⚛️

Bas Westerbaan bwesterb

⚛️
View GitHub Profile
#!/bin/sh
if [ "$IFACE" != eth0 ]; then
exit 0
fi
case "$MODE" in
start)
route add -host 144.76.73.47 dev eth0
route add -net default gw 144.76.73.47
import math
import random
from fractions import Fraction
D = 365
def ncr(n, r):
return math.factorial(n) / math.factorial(r) / math.factorial(n-r)
points = []
import os
import os.path
# Tests for suspicious folders used by finfisher.
# Source:
# http://belsec.skynetblogs.be/archive/2014/08/07/check-your-linuxservers-are-you-infected-with-the-finphisher-8252101.html
first = ['.fontconfig', '.gconf', '.gnome', '.gnome2', '.kde', '.local',
'.qt', '.ssh']
second = ['.config', '.bin', '.sbin', '.etc', '.cfg', '.apps']
@bwesterb
bwesterb / gist:cd32cfb563e9dff4c569
Created August 25, 2014 11:09
voorbeeld voor J
Dir.entries('.').each do |old|
next if old.end_with? '.rb'
next if ['.', '..'].include? old
new = old.split('-', 2)[0].strip + '.flac'
File.rename(old, new)
end
#!/usr/bin/env python
import os
import os.path
import subprocess
for fn in os.listdir('.'):
if not os.path.isfile(fn):
continue
if not fn.endswith('.fif'):
@bwesterb
bwesterb / gist:a699d64fe1d7d4f78bb9
Created October 31, 2014 07:10
recurse through directories
#!/bin/python
import os
import os.path
base_path = '.'
todo = [base_path]
while todo:
current_dir = todo.pop()
@bwesterb
bwesterb / bug.py
Created June 25, 2015 14:35
Popen bug in pypy?
import subprocess
while True:
p = subprocess.Popen(['cat'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
p.stdin.close()
p.wait()
--- /etc/xen/scripts/vif-route 2013-01-22 17:41:48.000000000 +0100
+++ /etc/xen/scripts/our-vif-route 2015-05-16 20:52:46.000000000 +0200
@@ -23,11 +23,37 @@
dir=$(dirname "$0")
. "${dir}/vif-common.sh"
+ip6_of()
+{
+ ip -6 addr show "$1" | perl -wane '/scope global/ && /inet6 (([0-9a-f]+:*)+)/ && print $1;'
+}
# autogenerated by Vagrantfile---
secrets:
chucknorris: 4fc80eba58ec111d80c428777b8607e2
mysql_forum: bfb170afc7d2751589f20bb98a8ff7c8
django_secret_key: 0a92901e77362f27240de17efae8e3fb
mysql_wiki: 3fe280c48f7820b3da7dffcdf4b09ffb
mysql_wolk: d8f4d98841e84ae9716a49548647015f
apikey: e363fb6984515c72522692d920870559
mailman_default: 0a9d5b9aed2f6cfa0ffb417b6da79f00
ldap_infra: 7d40946647e37313ac99f0169b8fed6c
keys:
laptop: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...
desktop: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...
oldDesktop: ssh-rsa AAAAC3NzaC1lZDI1NTE5AAAAI...
servers:
root@some-shared-server.com:
present:
- laptop
- desktop
absent: