This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Using Vim to view strace output | |
strace -o'!vim -R -' "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ~/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef A_DOT_H_INCLUDED | |
#define A_DOT_H_INCLUDED | |
#include "b.h" | |
struct a | |
{ | |
struct b *b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display integers as hex and decimal | |
import sys | |
def displayhook(item): | |
if isinstance(item, int) and not isinstance(item, bool): | |
print '0x{0:X} ({0})'.format(item) | |
elif isinstance(item, long): | |
print '0x{0:X}L ({0}L)'.format(item) | |
elif item is not None: | |
print repr(item) | |
sys.displayhook = displayhook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void *search_without_goto(const char *key) | |
{ | |
int i; | |
void *result; | |
for (i = 0; i < some_length; i++) { | |
if (strcmp(some_collection[i].key, key) == 0) | |
break; | |
} | |
if (i == some_length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nov 28 21:24:06.432882 kernel: radeon 0000:01:00.0: ring 0 stalled for more than 10092msec | |
Nov 28 21:24:06.441917 kernel: radeon 0000:01:00.0: GPU lockup (current fence id 0x0000000001ff9744 last fence id 0x0000000001ff9755 on ring 0) | |
Nov 28 21:24:06.455092 kernel: radeon 0000:01:00.0: ring 4 stalled for more than 10104msec | |
Nov 28 21:24:06.455374 kernel: radeon 0000:01:00.0: GPU lockup (current fence id 0x000000000100a400 last fence id 0x000000000100a401 on ring 4) | |
Nov 28 21:24:06.655161 kernel: radeon 0000:01:00.0: ring 3 stalled for more than 10080msec | |
Nov 28 21:24:06.655451 kernel: radeon 0000:01:00.0: GPU lockup (current fence id 0x0000000000d334fd last fence id 0x0000000000d3350e on ring 3) | |
Nov 28 21:24:06.935108 kernel: radeon 0000:01:00.0: ring 0 stalled for more than 10596msec | |
Nov 28 21:24:06.935390 kernel: radeon 0000:01:00.0: GPU lockup (current fence id 0x0000000001ff9744 last fence id 0x0000000001ff9755 on ring 0) | |
Nov 28 21:24:06.959090 kernel: radeon 0000:01:00.0: ring 4 stalled for more than 106 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from __future__ import print_function | |
from tempfile import TemporaryFile | |
from binascii import hexlify | |
from ctypes import * | |
class StructHelper(object): | |
def __get_value_str(self, name, fmt='{}'): | |
val = getattr(self, name) |