Skip to content

Instantly share code, notes, and snippets.

@dpryden
dpryden / ClassLoaderLeakExample.java
Created Oct 20, 2014
Example of a ClassLoader leak in Java
View ClassLoaderLeakExample.java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
@dpryden
dpryden / toxin
Created Apr 3, 2018
toxin: Script for running python or shell commands inside a .tox environment
View toxin
#!/bin/bash
# Run a command inside a Tox environment
if ! [[ -d .tox ]]; then
echo 'Cannot find .tox in this directory!'
exit 1
fi
if [[ "$1" == '-e' ]]; then
toxenv="$2"
shift 2
@dpryden
dpryden / api.py
Created Jan 15, 2019
Demo of a RESTful API server in Python using only the standard library.
View api.py
#!/usr/bin/env python3
"""Demo of a RESTful API server in Python, using only the standard library.
The API here is extremely simple:
* a POST request stores a JSON object (from the POST body) at the given path
* a GET request returns a JSON object stored at the given path
Example usage:
View run_subprocess.c
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
/*