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
| def b64len(b64str): | |
| """ | |
| Calculate the length in bytes of a base64 string. | |
| This function could decode the base64 string to a binary blob and count its | |
| number of bytes with len(). But, that's inefficient and requires more | |
| memory that really needed. | |
| Base64 encodes three bytes to four characters. Sometimes, padding is added | |
| in the form of one or two '=' characters. |
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
| from time import time | |
| from asyncio import sleep | |
| from .poll import NotReadyYet | |
| async def poll( | |
| func, | |
| timeout_s=30.0, polling_s=5.0, | |
| catchexcs=(NotReadyYet, ), pollcb=None, |
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
| """ | |
| Simple dictionary to object class. | |
| """ | |
| from collections import Mapping | |
| try: | |
| from pprintpp import pformat | |
| except ImportError: | |
| from pprint import pformat |
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
| /* | |
| * Auto-converter of arbitrary values to International System of Units (SI) | |
| * human readable prefix. | |
| * | |
| * Typical usage: | |
| * | |
| * const txpackets = 2450 | |
| * const txbytes = txpackets * 256 | |
| * const txtime = 2.0 | |
| * |
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
| def naturalsorted(iterable): | |
| """ | |
| Sort given iterable of strings using the "natural sorter" algorithm. | |
| :param iterable: An iterable that yield strings. | |
| :return: A list of elements in iterable naturally sorted. | |
| :rtype: list | |
| """ | |
| from re import split |
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
| from zlib import compress, Z_BEST_COMPRESSION | |
| # Compressing | |
| def compress_ratio(original, compressed): | |
| obytes = len(original) | |
| cbytes = len(compressed) | |
| return (obytes - cbytes) / obytes | |
| original = b'Hello World' |
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
| After Windows 10 "Creators" update the fucker removes Grub and fucks your dual boot. | |
| To restore a Ubuntu 16.04 installation with the following characteristics: | |
| - EFI mode. | |
| - GPT partition table. | |
| - One encrypted / partition. | |
| - One /boot partition. | |
| - One EFI partition. | |
| - Dual boot with Windows 10. |
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
| def lovewins(text='LoveWins'): | |
| def esc(*x): | |
| return '\033[' + ';'.join(x) + 'm' | |
| colors = [7, 1, 3, 63, 2, 4, 5, 7] | |
| for byte in text.encode('ascii'): | |
| print(''.join( | |
| ''.join([ |
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
| def interpolate(x0, y0, x1, y1, x): | |
| return (y0 * (x1 - x) + y1 * (x - x0)) / (x1 - x0) |
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 bash | |
| apt-get update && apt-get install -y --no-install-recommends libssl-dev flex bison && \ | |
| echo "Downloading libpcap" && \ | |
| cd /tmp && curl http://www.tcpdump.org/release/libpcap-1.7.4.tar.gz -o libpcap.tar.gz && \ | |
| tar -xf libpcap.tar.gz && cd /tmp/libpcap* && \ | |
| echo "Building libpcap" && \ | |
| ./configure && make && \ | |
| echo "Installing libpcap" && \ | |
| make install && \ |