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
""" ASN1 DER/BER symmetric parser/encoder. """ | |
import enum | |
def decode_varint(bytearr): | |
value = bytearr[0] & 0x7f | |
while bytearr.pop(0) & 0x80: | |
value = (value << 7) | (bytearr[0] & 0x7f) | |
return value | |
def encode_varint(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
#!/bin/bash | |
# remove shit from downloads | |
shopt -s nullglob dotglob | |
current_time=`date +%s` | |
max_age_days=${1:-30} | |
max_age_days=$((max_age_days)) |
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
__get_tmux_pane_contents() { | |
local cmd='for pane in `tmux list-panes -F "#{pane_id}"`; do tmux capture-pane -p -t $pane; done' | |
for word in `eval "$cmd"`; do | |
if [ ${#word} -ge ${FZF_MIN_WORD_LENGTH:-4} ]; then | |
echo "$word" | |
fi | |
done | awk '{ print length, $0 }' | sort -rn | cut -d' ' -f2- | uniq | |
} |
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
def bytes2int(data, byteorder='little', signed=False): | |
""" replicate int.from_bytes from python3 """ | |
if byteorder == 'little': | |
data = reversed(data) | |
elif byteorder != 'big': | |
raise ValueError("byteorder must be either 'little' or 'big'") | |
bl = bytearray(data) |
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
class HexDump(object): | |
""" | |
HexDump(data, width=16, groups=(2,4), prefix='') | |
Dump hex. | |
width - Number of bytes per dump line | |
groups - How to group the bytes, i.e where to put spaces. Ex: | |
(1,) - space after every byte |
NewerOlder