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()
@bwesterb
bwesterb / output-of-maried
Created May 5, 2011 21:19
Output of bwesterb/maried after dual upload on empty repository
74018 DEBUG cometServer.12:OPTIONS
74019 INFO cometServer.12:Request: 200 None
74019 INFO cometServer.13:Accepted connection from ('192.168.1.2', 49206)
74021 DEBUG cometServer.13:OPTIONS
74021 INFO cometServer.13:Request: 200 None
74313 INFO cometServer.14:Accepted connection from ('192.168.1.2', 49207)
74316 INFO cometServer.0yPWzZFY:Download started
74400 INFO cometServer.15:Accepted connection from ('192.168.1.2', 49208)
74402 INFO cometServer.0yPWzZFY:Download started
78602 WARNING mediaStore:Duplicate file b6cc27ec2a587df05504da8684eafa7f2412d6c82c063190192d8ff6a64102a873d832e9d99d9e273da4ea9031874c7aea19a803a589563c05a6686b46c978db
@bwesterb
bwesterb / gist:1082355
Created July 14, 2011 12:26
JavaScript Quine
phi = function(c) {
return eval("("+c+")").apply(null,
Array.prototype.slice.call(arguments, 1));
};
s11 = function(c, x) {
return "function(){"+
"return ("+c+").apply(null,["+
JSON.stringify(x)+"].concat("+
"Array.prototype.slice.call(arguments,0)));"+
@bwesterb
bwesterb / gist:1085773
Created July 15, 2011 23:26
Analysing space filling curves
from math import sin, cos, pi, sqrt, log
import random
import Image
import ImageDraw
algs = (('gosper', 'x', 6, {
'x': 'x+yf++yf-fx--fxfx-yf+',
'y': '-fx+yfyf++yf+fx--fx-y'}),
('square', 'x', 4, {
'x': 'xf-f+f-xf+f+xf-f+f-x'}),