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/bash | |
PATHS='*.go internal' | |
# Run from project root | |
cd "$(dirname "${BASH_SOURCE[0]}")" | |
output="$(gofmt -l $PATHS)" | |
if [ ! -z "$output" ]; then | |
echo -e "The following files are not properly formatted:\n" |
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 | |
import math | |
def round_down(n, d=8): | |
# https://stackoverflow.com/a/43533589/119527 | |
d = 10 ** d | |
return math.floor(n * d) / d | |
def human_size(n, decimal_places=2): | |
n = float(n) |
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 | |
import sys | |
from ctypes import * | |
assert sys.version_info >= (3,5) | |
class Struct(LittleEndianStructure): | |
_fields_ = [ | |
('a', c_uint32), | |
('b', c_uint32), |
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
using System; | |
using System.Text; | |
using System.Threading; | |
using System.Windows.Forms; | |
using WinformsExceptions; | |
static class Program | |
{ | |
/// <summary> |
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 time | |
import struct | |
f = open(r'\\.\pipe\NPtest', 'r+b', 0) | |
i = 1 | |
while True: | |
s = 'Message[{0}]'.format(i).encode('ascii') | |
i += 1 | |
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/bash | |
if [[ $# -lt 2 ]]; then | |
echo "Usage: `basename $0` oldrepo newrepo" | |
exit 1 | |
fi | |
# http://stackoverflow.com/q/1848415/ | |
OLDREPO=${1%/} | |
NEWREPO=$2 |
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) |
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
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
# 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 |