Skip to content

Instantly share code, notes, and snippets.

View ralt's full-sized avatar

Florian Margaine ralt

View GitHub Profile
Handling request for http://margaine.com/
debugger invoked on a HTTPICKLE::HTTPICKLE-CONDITION in thread
#<THREAD "main thread" RUNNING {1003266DB3}>:
on incoming HTTP REQUEST
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
[ralt@zap httpickle]$ PORT=4445 ./build/httpickle
Handling request for /
debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {1003266AC3}>:
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [PRINT-HEADERS] Print the headers and their values
# Laap
[ralt@zap wrk]$ curl localhost:9092
Pong
[ralt@zap wrk]$ ./wrk -H "Connection: close" -t12 -c400 -d10s http://localhost:9092
Running 10s test @ http://localhost:9092
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 11.48ms 75.29ms 1.67s 98.27%
Req/Sec 2.97k 1.62k 7.21k 61.38%
# Lisp event loop-based HTTP server
[ralt@zap wrk]$ ./wrk -t12 -c400 -d10s http://localhost:5560
Running 10s test @ http://localhost:5560
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 11.79ms 76.32ms 1.67s 98.24%
Req/Sec 3.13k 2.17k 8.72k 63.38%
347075 requests in 10.09s, 15.23MB read
Socket errors: connect 0, read 0, write 0, timeout 12
Requests/sec: 34395.16
# 1000 concurrent HTTP requests to 127.0.0.1 where default nginx is sitting
# Using golang
[ralt@zap golang]$ time ./golang
real 0m0.083s
user 0m0.165s
sys 0m0.087s
[ralt@zap golang]$ time ./golang
@ralt
ralt / ssh-server.py
Created May 7, 2016 20:31
Paramiko interactive subprocess
# In the paramiko server... this is super ugly.
from subprocess import Popen, PIPE
import select
def _read_chan(chan, stdin):
x = chan.recv(1)
if ord(x) == 13:
chan.send("\r\n")
stdin.write("\n")
else:
@ralt
ralt / is_frozen.c
Created April 13, 2016 21:46
FIGETFROZEN in action
root@localhost:/mnt# gcc is_frozen.c -o is_frozen
root@localhost:/mnt# ./is_frozen /
frozen status: 0
root@localhost:/mnt# fsfreeze --freeze /
root@localhost:/mnt# ./is_frozen /
frozen status: 4
root@localhost:/mnt# fsfreeze --unfreeze /
root@localhost:/mnt# ./is_frozen /
frozen status: 0
@ralt
ralt / git-shred
Created February 3, 2016 16:45
git shred - burn a file with fire
#!/bin/bash
if [ ! -z "$1" ]; then
echo "$1 doesn't exist."
exit 1
fi
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch $1" \
--prune-empty --tag-name-filter cat -- --all
@ralt
ralt / backup.sh
Created November 10, 2015 08:37
Duplicity backups on S3
export PASSPHRASE="REALLY COMPLICATED PASSWORD :)"
REM_IF_OLDER="54W"
FULL_IF_OLDER="8W"
ORIG_DIR=/home/foo/Backup
BACKUP_DIR=s3://s3-eu-west-1.amazonaws.com/foo/bar
duplicity --s3-use-new-style --force --s3-european-buckets remove-older-than $REM_IF_OLDER $BACKUP_DIR
duplicity --s3-use-new-style --s3-european-buckets --full-if-older-than $FULL_IF_OLDER \
--exclude /home/foo/Backup/Dotfiles/gnupg/random_seed \
@ralt
ralt / fix-partitioned-loop-device.patch
Last active November 5, 2015 17:17
Patch to fix mkfs.btrfs on partitioned loop devices.
diff --git a/utils.c b/utils.c
index f10c178..04207b5 100644
--- a/utils.c
+++ b/utils.c
@@ -937,22 +937,20 @@ static int is_loop_device (const char* device) {
static int resolve_loop_device(const char* loop_dev, char* loop_file,
int max_len)
{
- int ret;
- FILE *f;