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 get_progress(current, total): | |
percent = int(round(current / total, 2) * 100) | |
progress = round(percent * .5) | |
return '[{}{}] {}%'.format('#' * progress, ' ' * (50 - progress), percent) |
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
/* | |
NOTICE: This theme DOES NOT support the triple-panel layout. | |
NOTICE: This theme DOES NOT support all HTTP request types. Since we didn't need them, this only supports GET and POST. | |
NOTICE: This theme DOES NOT support a full Highlight.js theme (again, we only needed partial support). | |
*/ | |
/* Color variables */ | |
@primary-color: #2eb888; | |
@secondary-color: #2eb8b2; | |
@primary-color-light: lighten(@primary-color, 17%); |
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
# Standard library imports | |
import logging | |
import json | |
def load_document(string): | |
document = None | |
try: | |
document = json.loads(string) | |
except: |
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
# Standard library imports | |
import ctypes | |
# Keyboard scan codes | |
SCANCODE_ESCAPE = 0x01 | |
SCANCODE_1 = 0x02 | |
SCANCODE_2 = 0x03 | |
SCANCODE_3 = 0x04 | |
SCANCODE_4 = 0x05 | |
SCANCODE_5 = 0x06 |
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
# Standard-library imports | |
from random import Random | |
VOWELS = 'aeiou' | |
CONSONANTS = 'bcdfghjklmnpqrstvwxyz' | |
def get_seeded_name(seed, length=8): | |
random = Random(seed) | |
word = '' |
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
# Standard library imports | |
import threading | |
import queue | |
class ConcurrentFunction: | |
def __init__(self, function, args=(), kwargs={}): | |
self.function = function | |
self.args = args | |
self.kwargs = kwargs |
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
# Standard library imports | |
import re | |
# Third-party imports | |
import editdistance | |
import unidecode | |
def convert_to_expression(string): | |
patterns = ['\w', '\s'] | |
expression = '' |
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
# Standard library imports | |
import base64 | |
import io | |
import pathlib | |
import zipfile | |
def pack_files(file_names): | |
zip_buffer = io.BytesIO() | |
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_LZMA) as zip_file: |
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
# Standard library imports | |
from time import time | |
# Third-party imports | |
from humanfriendly import format_timespan | |
class Progress: | |
def __init__(self, total): |
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
# Standard library imports | |
from datetime import datetime | |
from pathlib import Path | |
from pickle import dumps, loads | |
class CachedObject: | |
def __init__(self, value): | |
self.value = value | |
self.cached_at = datetime.now() |
OlderNewer