Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# Invoke n instances of sudo in parallel. This works fine in all machines I've
# tried this on, except Windows Azure VMs, where occasionally invocations to
# sudo take ~5s to complete when n > 1.
# Tested on a Standard_A1 instance w/Ubuntu Utopic, kernel 3.16.0-34-generic.
import subprocess
import sys
import time
#!/usr/bin/python
# vim: set expandtab:ts=2:sw=2
import argparse
import bluetooth
import struct
import sys
def checksum(msg):
checksum = 0
#!/usr/bin/python
import argparse
import random
import subprocess
import sys
import time
PREFIX = '/sbin/ip netns exec'
@lhchavez
lhchavez / strace.py
Created February 11, 2016 06:13
strace wrapper to display the read/written files of a process tree
#!/usr/bin/python
import argparse
import collections
import os
import os.path
import re
import subprocess
import sys
import threading
#!/bin/bash
set +x
sudo apt-get install -y autoconf automake binutils-dev build-essential cmake g++-4.9 gawk git \
libbz2-dev libc-client-dev libldap2-dev \
libc-client2007e-dev libcap-dev libcurl4-openssl-dev libdwarf-dev libelf-dev \
libexpat-dev libgd2-xpm-dev libgoogle-perftools-dev libicu-dev \
libjemalloc-dev libmcrypt-dev libmemcached-dev libmysqlclient-dev libncurses-dev \
libonig-dev libpcre3-dev libreadline-dev libtbb-dev libtool libxml2-dev zlib1g-dev \
#!/usr/bin/python3
from Crypto.Signature import PKCS1_v1_5
from Crypto.PublicKey import RSA
import argparse
import socket
import struct
import sys
ADB_AUTH_TOKEN = 1
// Benchmark Time CPU Iterations
// -----------------------------------------------------
// BM_DynamicCast 1073 ns 1074 ns 630631
// BM_StaticCast 452 ns 452 ns 1552106
// BM_TaggedCast 59 ns 59 ns 11111111
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <benchmark/benchmark.h>
@lhchavez
lhchavez / ClangIwyu.cpp
Created January 3, 2017 14:52
WIP of an IWYU ClangTool
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Path.h"
@lhchavez
lhchavez / mkns.cpp
Created October 22, 2017 02:14
Create namespaces and bind their nsfs FDs
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
@lhchavez
lhchavez / adbddb.cpp
Created January 19, 2018 01:30
Android Debug Bridge Debugger
#include <errno.h>
#include <fcntl.h>
#include <linux/usb/ch9.h>
#include <linux/usbdevice_fs.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstdio>
#include <iostream>