Skip to content

Instantly share code, notes, and snippets.

View erikdubbelboer's full-sized avatar

Erik Dubbelboer erikdubbelboer

View GitHub Profile
@erikdubbelboer
erikdubbelboer / setuser.go
Created September 29, 2013 06:41
Change the user and group of the current thread. Currently mostly unusable because of: http://code.google.com/p/go/issues/detail?id=1435
/*
#include <stdlib.h> // free()
#include <grp.h>
#include <pwd.h>
*/
import "C"
#!/bin/bash
while true; do
rsync -v --progress --partial files* example.com::erik
if [ "$?" = "0" ]; then
echo "rsync completed normally."
exit
else
echo "rsync failure, retrying..."
sleep 60
var mysql = require('mysql'); // npm install mysql@2.0.0-alpha7
var client = mysql.createConnection({
"host" : "127.0.0.1",
"port" : 3306,
"user" : "user",
"password": "password",
"database": ""
});

Keybase proof

I hereby claim:

  • I am erikdubbelboer on github.
  • I am erikdubbelboer (https://keybase.io/erikdubbelboer) on keybase.
  • I have a public key whose fingerprint is A88D 9578 C2CB C1D2 9F33 B036 50EB FD5E DAB6 324F

To claim this, I am signing this object:

@erikdubbelboer
erikdubbelboer / gist:f20ef392607203fb591e
Created August 29, 2014 18:50
Sort a csv in python using limited memory
import os
import csv
import json
import heapq
def sortCSV(infile, column, reverse, cast):
outfiles = []
if reverse:
@erikdubbelboer
erikdubbelboer / gist:e1999c3709cbbe63f44e
Created January 28, 2015 10:59
PHPRedisAdmin Nginx
server {
include /etc/nginx/server.conf;
listen 80;
server_name dubbelboer.com;
root /var/www/dubbelboer.com;
index index.php index.html;
location ~ \.php$ {
package gziphandler
import (
"compress/gzip"
"log"
"net/http"
"strings"
"sync"
)
@erikdubbelboer
erikdubbelboer / binlogfix.sh
Created March 16, 2015 06:44
Run binlogfix on all tags without taking away too much cpu from normal jobs
#!/bin/bash
renice -n 19 $$ >&2
for tag in `ddfs ls | grep -- -[ico]1- | sort -k 3n -t '-'`; do
while true; do
if [[ `ps ax | grep python | wc -l` -lt 20 ]]; then
break
fi
sleep 2
@erikdubbelboer
erikdubbelboer / output.txt
Last active February 1, 2016 08:31
net.errClosing use case
erik$ go version
go version go1.4.1 darwin/amd64
erik$ go test -v usecase_test.go
=== RUN TestUseOfClosedNetworkConnection
--- PASS: TestUseOfClosedNetworkConnection (0.01s)
usecase_test.go:15: request start
usecase_test.go:34: timeout
usecase_test.go:17: request end
PASS
ok command-line-arguments 0.019s
@erikdubbelboer
erikdubbelboer / client.go
Created March 22, 2015 07:52
Testing UDP packet loss
package main
import (
"encoding/binary"
"log"
"net"
"time"
)
func main() {