Skip to content

Instantly share code, notes, and snippets.

@phihag
phihag / filehandles.go
Created April 29, 2014 11:17
Demo file for file handle count question on so
package main
import "fmt"
import "io/ioutil"
func main() {
files, _ := ioutil.ReadDir("/tmp/files")
for _, file := range files {
_, err := ioutil.ReadFile("/tmp/files/" + file.Name())
@phihag
phihag / addresses.log
Created July 11, 2014 06:56
OpenVPN problem - Why is the default gateway 10.222.0.5?
# On the server:
$ ip a s dev tun0
15: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.222.0.1 peer 10.222.0.2/32 scope global tun0
# Client output:
...
Fri Jul 11 08:55:32 2014 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Fri Jul 11 08:55:32 2014 [n.phihag.de] Peer Connection Initiated with [AF_INET]174.34.171.91:1194
import multiprocessing as mp
def worker(filex):
""" reading lots of data """
raw = filter(lambda x: len(x.split())>3,
open(filex).readlines())
data = {}
# putting all the data in the data dictionary
return data
@phihag
phihag / gist:1859087
Created February 18, 2012 12:29
Thread safety demo
#!/usr/bin/env python
import os
import subprocess
import sys
from threading import Thread
from time import sleep
@phihag
phihag / thread-safety-debian.py
Created February 19, 2012 17:44
Thread safety demo on debian
#!/usr/bin/env python
import os
import subprocess
import sys
from threading import Event, Thread
from time import sleep
@phihag
phihag / emptyfile.js
Created March 20, 2012 12:35
Empty file written - demo code
var fs = require('fs');
var file_tree = ['test1.txt', 'test2.txt'];
var data = ['d1', 'd2'];
for(i in file_tree) {
fp = fs.createWriteStream(file_tree[i]);
for(i in data) {
@phihag
phihag / chroot-breakout.py
Created April 5, 2012 17:36
Break out of chroot - Demo
import os
os.chroot('/tmp')
os.chroot('../../')
print(os.listdir('/'))
14x arduino uno Rev3
24,40€ http://www.watterott.com/de/Arduino-Uno
15x arduino Proto Shield - Wireless SD Shield
23,68€ http://www.watterott.com/de/Shield-Wireless-SD-Shield
14x Digi XB24-AWI-001
25,95€ http://www.reichelt.de/Bausaetze-Module/ZIGBEE-XBEE-D/index.html?ACTION=3&GROUPID=3636&ARTICLE=108350&SHOW=1&START=0&OFFSET=16&
arduino-Netzworkemulator
Entwickeln eines Emulators für <a
href="http://arduino.cc/">arduino</a> und IEEE 802.15.4-Netzwerke
<p><a href="http://arduino.cc/">arduino</a> ist eine
Hardware-Plattform für einfache Computer, z.B. Sensorknoten,
diff -r 9d3609c787c4 build_debian.sh
--- a/build_debian.sh Tue May 08 12:35:21 2012 +0200
+++ b/build_debian.sh Tue May 08 13:32:19 2012 +0200
@@ -144,6 +144,11 @@
bin/python bootstrap.py -c buildout_${buildout_variant}.cfg
bin/buildout -Nc buildout_${buildout_variant}.cfg
+# Pull and update adhocracy changes.
+# Since this script is targeting test users / new developers, we do want this.
+# Because experienced developers may not want the behavior, we do *not* set always-update = true for all users in buildout_development.cfg