This file contains hidden or 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 sys | |
s = open(sys.argv[1], 'rb').read() | |
lines = [] | |
while s: | |
bytes = ['0x%02x' % ord(ch) for ch in s[:16]] | |
lines.append(' ' + ', '.join(bytes) + ',' + '\n') | |
s = s[16:] | |
print ''.join(lines) |
This file contains hidden or 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 sys, os, os.path | |
def find_bencode_end(s): | |
if not s: | |
raise RuntimeError('Not a valid bencode blob.') | |
if s[0] == 'i': | |
if len(s) < 2: | |
raise RuntimeError('Not a valid bencode blob.') | |
if s[1:3] == '0e': | |
return 3 |
This file contains hidden or 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 sys, os.path | |
from xml.etree import ElementTree | |
import xml.dom.minidom | |
def process_vcxproj_file(fname): | |
with open(fname, 'rb') as fin: | |
proj = fin.read() | |
add_optimize_after = ' <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r\n <ClCompile>' | |
proj = proj.replace(add_optimize_after, add_optimize_after + '\r\n <Optimization>Disabled</Optimization>') |
This file contains hidden or 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
""" | |
Generates CRC tables. Run as follows. | |
gencrctable.py <polynom> -w <width> | |
# for CRC-32 | |
gencrctable.py 0x04C11DB7 -w 32 | |
# for CRC-32C | |
gencrctable.py 0x1EDC6F41 -w 32 |
This file contains hidden or 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 argparse | |
import sys | |
def _main(): | |
ap = argparse.ArgumentParser() | |
ap.add_argument('--min-range-length', '-n', type=int, default=3) | |
ap.add_argument('input') | |
args = ap.parse_args() |