Skip to content

Instantly share code, notes, and snippets.

import re
import io
class FtraceEventParser(object):
"""FTraceEventParser parses the text form of a single event
to a tuple of all the event's arguments.
Example usage:
import argparse
import paramiko.client
import time
parser = argparse.ArgumentParser(description='stress test SSH channels')
parser.add_argument('-H', '--host', help='host to test')
parser.add_argument('-u', '--user', help='user to use SSH with')
parser.add_argument('-p', '--pwd', help='password to use SSH with')
elazarl / checkexist.c
Created Nov 29, 2017
constantly polls until a file disappears
View checkexist.c
#include <argp.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
static char args_doc[] = "FILES to poll until missing";
elazarl /
Last active May 25, 2017
runs QEMU command, creating an isolated bridge with NAT internet access there, runs SSH daemon and adds bridge to QEMU's command line
This scripts creates an isolated network environment,
and adds necessary configuration to the given QEMU command line to run
in this network.
WARNING: for development purposes only, allows PE for every user on the host.
Typical Usage
elazarl / setup xen environment
Last active Dec 4, 2016
Setup Xen development environment
View setup xen environment
setup xen environment
elazarl /
Created Jul 5, 2014
hexdump to dump memory in gdb's format
alias gdbdump='hexdump -e '\''"0x%04_ax: " 8/1 "0x%02x\t" "\n"'\'''
# hexdump format is: '"0x%04_ax: " 8/1 "0x%02x\t" "\n"'
elazarl /
Created Sep 13, 2016
Convert .h files using ifdef guard to use pragma once
import sys
import os
import tempfile
import re
starts_with_ifndef = re.compile(r'^\s*#ifndef.*\n#define.*\n')
ends_with_endif = re.compile(r'#endif.*$')
elazarl / objdump-hexdump.c
Created Aug 8, 2016
C hexdump in objdump -x format
View objdump-hexdump.c
#include <ctype.h>
#include <stdio.h>
struct buf {
unsigned char *p;
uint64_t len;
void hexdump(struct buf buf) {
int i = 0;
elazarl /
Created Jun 28, 2016
List vagrant box download URLs
if [ -z "$@" ]; then
echo Example usage:
echo $0 ubuntu/xenial64
echo Output:
echo ...
exit 1
elazarl / jitter.c
Last active Apr 21, 2016
Compare rdtsc time passed before and after a call to nanosleep
View jitter.c
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <regex.h>
#include <time.h>
#include <stdbool.h>