Skip to content

Instantly share code, notes, and snippets.

View tizz98's full-sized avatar
🍍

Elijah Wilson tizz98

🍍
View GitHub Profile
@tizz98
tizz98 / app.py
Created November 11, 2021 19:20
Autocomplete trie with FastAPI
from dataclasses import dataclass, field
from operator import itemgetter
import time
from typing import Dict
from fastapi import FastAPI
import tqdm
@dataclass
@tizz98
tizz98 / gist:f97d380148926bc193fcd6bcf8700d62
Created May 28, 2021 14:35 — forked from tott/gist:3895832
create cpu load in python
#!/usr/bin/env python
"""
Produces load on all available CPU cores
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
while True:
#!/usr/bin/env python3
import subprocess
import urllib.request
from tqdm import tqdm
latest_url = "https://zoom.us/client/latest/zoom_amd64.deb"
class DownloadProgressBar(tqdm):
@tizz98
tizz98 / duration.py
Created May 2, 2019 14:38
simple python duration recipe
class Duration:
"""
>>> d = Duration(days=1)
>>> d.hours == 24.0
True
>>> d.minutes == 1440.0
True
>>> d.seconds == 86400.0
True
"""
@tizz98
tizz98 / img.go
Created January 6, 2019 19:37
Jpeg to Png with golang
package app
import (
"bytes"
"fmt"
"image/jpeg"
"image/png"
"net/http"
"github.com/pkg/errors"

Keybase proof

I hereby claim:

  • I am tizz98 on github.
  • I am tizz98 (https://keybase.io/tizz98) on keybase.
  • I have a public key ASD4-YYlqbRFDP1y2ZoXGLFkOA_whshPRYSwbHzG6AK4Ngo

To claim this, I am signing this object:

@tizz98
tizz98 / cc_sc.py
Last active October 25, 2017 20:24
Will convert a string to valid python class and/or variable names. (useful for convention over configuration)
def clean_name(name, replacement_char):
# Remove invalid characters
new_class_name = re.sub('[^0-9a-zA-Z_]', replacement_char, name)
# Remove leading characters until we find a letter or underscore
return re.sub('^[^a-zA-Z_]+', replacement_char, new_class_name)
print(clean_name('123something** cool\\vv__', '*').title().replace('*', '')) # CamelCase
print(clean_name('123something** cool\\vv__', '_')) # snake_case

Keybase proof

I hereby claim:

  • I am tizz98 on github.
  • I am tizz98 (https://keybase.io/tizz98) on keybase.
  • I have a public key ASCQ_llVmVUQmxtrEso64HejZRW25rX--Tux2l_ntjRMqQo

To claim this, I am signing this object:

class Animal:
SOUND = None
def make_sound(self):
raise NotImplementedError
class Dog(Animal):
SOUND = 'woof'
@tizz98
tizz98 / restrict.py
Last active March 19, 2017 20:44
Restrict python method calls
import functools
import inspect
class RestrictException(Exception):
pass
class restrict(object):
def __init__(self, ok_class, ok_function=None, exc_msg=None):