Skip to content

Instantly share code, notes, and snippets.

View Avlyssna's full-sized avatar

Dennis Avlyssna

  • Omnipresent
  • 05:46 (UTC -05:00)
View GitHub Profile
def get_progress(current, total):
percent = int(round(current / total, 2) * 100)
progress = round(percent * .5)
return '[{}{}] {}%'.format('#' * progress, ' ' * (50 - progress), percent)
@Avlyssna
Avlyssna / variables-seabed.less
Last active August 2, 2017 06:01
A stripped-down, compact Aglio theme
/*
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%);
# Standard library imports
import logging
import json
def load_document(string):
document = None
try:
document = json.loads(string)
except:
# 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
# Standard-library imports
from random import Random
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
def get_seeded_name(seed, length=8):
random = Random(seed)
word = ''
# Standard library imports
import threading
import queue
class ConcurrentFunction:
def __init__(self, function, args=(), kwargs={}):
self.function = function
self.args = args
self.kwargs = kwargs
# Standard library imports
import re
# Third-party imports
import editdistance
import unidecode
def convert_to_expression(string):
patterns = ['\w', '\s']
expression = ''
# 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:
# Standard library imports
from time import time
# Third-party imports
from humanfriendly import format_timespan
class Progress:
def __init__(self, total):
# 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()