Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Margaine ralt

View GitHub Profile
View gist:c72f7274f2b4ca218a90f956601f62c6
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):
View gist:b3a78fb2d1a1dfd5ee63c153454afe4e
[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
View gist:40f157d0fc684ce6490bac412870eb62
# 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%
View gist:18a8a9e3ad8e1877d8ab2b7c0fcb2877
# 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
View gist:26a45b66b45741a928c6d89e9be4910d
# 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
Paramiko interactive subprocess
View ssh-server.py
# 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 Apr 13, 2016
FIGETFROZEN in action
View is_frozen.c
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 Feb 3, 2016
git shred - burn a file with fire
View git-shred
#!/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 Nov 10, 2015
Duplicity backups on S3
View backup.sh
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 Nov 5, 2015
Patch to fix mkfs.btrfs on partitioned loop devices.
View fix-partitioned-loop-device.patch
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;