Skip to content

Instantly share code, notes, and snippets.

View gist:7412cdfa70833e399c6a91f5dd1da373
[cargobomb-prod cargobomb]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 15G 92K 15G 1% /dev
tmpfs 15G 72K 15G 1% /dev/shm
/dev/xvda1 99G 31G 68G 31% /
/dev/xvdb 985G 801G 134G 86% /home/ec2-user/cargobomb/work
[cargobomb-prod cargobomb]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 15G 92K 15G 1% /dev
tmpfs 15G 72K 15G 1% /dev/shm
View main.rs
use std::io::{BufRead, BufReader};
use std::process::{Child, Command, Stdio};
fn main() {
for id in 1..64_000 {
let mut child = Command::new("echo").arg(id.to_string())
.stdout(Stdio::piped()).stderr(Stdio::piped())
.spawn().unwrap();
output(&mut child, false);
child.wait().unwrap();
@aidanhs
aidanhs / gist:a25a6131155834b4c483
Last active Aug 29, 2015
golang gdb script hackery
View gist:a25a6131155834b4c483
--- runtime-gdb.py 2015-05-05 17:03:21.520510629 +0100
+++ runtime-gdb-hacks.py 2015-05-05 17:05:24.416677753 +0100
@@ -369,6 +369,41 @@
ptr = ptr[linkfield]
+class AidanCmd(gdb.Command):
+ "List all goroutines."
+
+ def __init__(self):
View gist:615c5867fc0373b38276

The instructions are:

$ go build udocker.go
$ chgrp docker udocker
$ chmod g+s udocker
$ mv udocker /usr/local/bin

I have performed the first three and therefore have this:

@aidanhs
aidanhs / gist:5ac9088ca0f6bdd4a370
Last active Jul 29, 2022
Rust binary tree worked example
View gist:5ac9088ca0f6bdd4a370

% Let's build a binary tree!

Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:

  1. must have a value
  2. may or may not have left and/or right children

So we can describe a single node like this:

@aidanhs
aidanhs / srv.js
Created Nov 20, 2014
Interrupted webserver
View srv.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('echo /');
console.log('kill me now');
setTimeout(function () {
res.write('tmp/xx\n');
}, 50000);
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');
View gist:69ad2d7c8959908d64b1
int main(void) {
int x = EM_ASM_INT({
Module.print('I received: ' + $0);
return $0 + 1;
}, 100)
return x;
}
View Makefile
.PHONY: clean do
CFLAGS=-O0 -m32
EMFLAGS=\
--memory-init-file 0
do: clean x.o y.o z.o
emar rc libtest.a y.o
emar rc libtest.a x.o
emranlib libtest.a
View gist:7796266
dd if=/dev/urandom bs=1M count=1000 of=/tmp/bigfile
# Note! This will cause your computer to slow down while it puts
# all files it's accessing back in memory
sudo sync
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
sleep 5
dd if=/tmp/bigfile bs=1M of=/dev/null
View conn.go
package main
import (
"database/sql"
"database/sql/driver"
"net/http"
"runtime"
"time"
)