Skip to content

Instantly share code, notes, and snippets.

@aidanhs
aidanhs / gist:5ac9088ca0f6bdd4a370
Last active March 19, 2024 16:01
Rust binary tree worked example

PLEASE DON'T USE THIS GUIDE

It's over 9 years old (as of 2024-02-18), there are many better guides! You might like https://rust-unofficial.github.io/too-many-lists/

% 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
@aidanhs
aidanhs / main.rs
Created September 21, 2016 14:11
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();
[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
@aidanhs
aidanhs / gist:5996985
Last active May 9, 2017 23:16
emscripten unicode bug

emtest("😇") = "ߘ"

@aidanhs
aidanhs / gist:7796266
Last active December 30, 2015 07:29
bench
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
package main
import (
"database/sql"
"database/sql/driver"
"net/http"
"runtime"
"time"
)
```
2013/11/22 18:15:26 2c9e825beb3b2c37d0a4d9c5625e10384bc6433c4a08a19b2092820a783bae4a: Failed to umount filesystem: Umount: Failed to umount /var/lib/docker/containers/2c9e825beb3b2c37d0a4d9c5625e10384bc6433c
4a08a19b2092820a783bae4a/rootfs
panic: runtime error: close of closed channel
goroutine 24 [running]:
runtime.panic(0x8eb1e0, 0x101f915)
/usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/dotcloud/docker.(*Container).monitor(0xc210062c40)
/go/src/github.com/dotcloud/docker/container.go:1232 +0x512
@aidanhs
aidanhs / gist:6792200
Created October 2, 2013 11:14
Bench hg, git, bup for linear history of a large file with inserts and appends
set -e
# Clean up previous test
rm log.log || true
rm -rf .git .hg .bup
# Specify how our file is going to be constructed
NUMS="00 01 02 03 04 05 06 07 08 09"
F1="00 "
F2="00 01 02 "
// ==UserScript==
// @name CoffeeTest
// @namespace test
// @version 0.1
// @grant none
// @require http://jashkenas.github.io/coffee-script/extras/coffee-script.js
// @match http://example.iana.org/
// ==/UserScript==
/*
@aidanhs
aidanhs / gist:615c5867fc0373b38276
Created April 27, 2015 15:53
udocker exploit

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: