Skip to content

Instantly share code, notes, and snippets.

View JonathonReinhart's full-sized avatar

Jonathon Reinhart JonathonReinhart

View GitHub Profile
@JonathonReinhart
JonathonReinhart / a.h
Created October 15, 2016 23:08
Circular includes
#ifndef A_DOT_H_INCLUDED
#define A_DOT_H_INCLUDED
#include "b.h"
struct a
{
struct b *b;
};
@JonathonReinhart
JonathonReinhart / sample_output
Created July 29, 2016 15:12
Show Ethernet drivers on Linux
$ ~/what_eth_drivers.sh
eth0 [52:54:00:aa:bb:cc]: virtio_net (up)
eth1 [52:54:00:dd:ee:ff]: virtio_net (up)
eth2 [52:54:00:99:88:77]: virtio_net (up)
lo [00:00:00:00:00:00]: (unknown)
@JonathonReinhart
JonathonReinhart / vimstrace
Created July 28, 2016 14:56
Vim frontend to strace
#!/bin/sh
# Using Vim to view strace output
strace -o'!vim -R -' "$@"
#!/usr/bin/env python
import BaseHTTPServer, SimpleHTTPServer
import ssl
import sys
import argparse
ap = argparse.ArgumentParser()
ap.add_argument('--certfile')
ap.add_argument('--keyfile')
ap.add_argument('--port', type=int, default=443)
Windows (PowerShell) (DER format):
Invoke-WebRequest -UseBasicParsing http://example.com/example.cer -OutFile example.cer
certutil.exe -addStore "Root" example.cer
Debian 8 (PEM format):
# wget -O /usr/local/share/ca-certificates/example.crt http://example.com/example.cer
# update-ca-certificates
@JonathonReinhart
JonathonReinhart / hexdump.py
Last active July 23, 2022 00:12 — forked from 7h3rAm/hexdump.py
hexdump implementation in Python
import string
def hexdump(src, length=16, sep='.'):
DISPLAY = string.digits + string.letters + string.punctuation
FILTER = ''.join(((x if x in DISPLAY else '.') for x in map(chr, range(256))))
lines = []
for c in xrange(0, len(src), length):
chars = src[c:c+length]
hex = ' '.join(["%02x" % ord(x) for x in chars])
if len(hex) > 24:
@JonathonReinhart
JonathonReinhart / SConstruct
Last active January 6, 2024 06:42
mkdir -p implemented in C
env = Environment(
CCFLAGS = ['-Wall', '-Werror'],
)
env.Program('mkdir_p_test', ['mkdir_p.c', 'test.c'])
@JonathonReinhart
JonathonReinhart / .gitconfig
Last active January 22, 2016 14:33
My Git config
[user]
email = jonathon.reinhart@gmail.com
name = Jonathon Reinhart
[color]
ui = true
[core]
# I can exclude my own editor's files; no need to include in project .gitignore
excludesfile = ~/.gitignore_global
editor = vim
[push]
@JonathonReinhart
JonathonReinhart / docker_config_temp.sh
Last active February 19, 2016 18:18
Prevent docker client from saving credentials to disk
#!/bin/sh
# This prevents docker config from persisting to disk.
# Place this file in /etc/profile.d/ to happen automatically at login for all users.
# JRR 2015-12-17
# See:
# https://github.com/docker/docker/issues/10318
# https://github.com/docker/docker/issues/18708
dockercfgdir="/dev/shm/dockercfg-$(id -un)"
@JonathonReinhart
JonathonReinhart / hexdump.c
Created October 28, 2015 21:39
Hexdump in C
// Derived from http://stackoverflow.com/a/7776146/119527
void fhexdump(FILE *f, const void *addr, size_t len, const char *addrfmt, size_t baseaddr)
{
size_t i;
unsigned char buff[17];
const unsigned char *pc = addr;
// Process every byte in the data.
for (i = 0; i < len; i++) {