Skip to content

Instantly share code, notes, and snippets.

View eivl's full-sized avatar

Eivind Teig eivl

  • Amedia
  • Sarpsborg, Norway
  • X @eivl
View GitHub Profile

Input validation ensures that the data we receive from a user can be manipulated without causing errors or bugs in the subsequent code. You've likely seen something similar to the following two code snippets, each for taking a string from input and converting it to an int:

#using isdigit
if val.isdigit(): val = int(val)

#using try/except
try: val = int(val)
except ValueError: print("Invalid, try again")
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
@eivl
eivl / main.py
Created February 25, 2023 18:17
Descriptor talk on python discord
'''
1: Data descriptor
2: self.__dict__['d']
3: non-data descriptor
__slots__
__get_attr__
__get_attribute__
'''
(()=>{})[({}+[])[+!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![]]+((+!![]/+[])+[])[+!![] + +!![] + +!![] + +!![]]+(![]+[])[+!![] + +!![] + +!![]]+({}+[])[+!![] + +!![] + +!![] + +!![] + +!![] + +!![]]+(!![]+[])[+!![]]+(!![]+[])[+!![] + +!![]]+({}+[])[+!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![] + +!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![]]+(!![]+[])[+!![]]](({}+[])[+!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![]]+((+!![]/+[])+[])[+!![] + +!![] + +!![] + +!![]]+(![]+[])[+!![] + +!![] + +!![]]+({}+[])[+!![]]+([]+[])[({}+[])[+!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![]]+((+!![]/+[])+[])[+!![] + +!![] + +!![] + +!![]]+(![]+[])[+!![] + +!![] + +!![]]+({}+[])[+!![] + +!![] + +!![] + +!![] + +!![] + +!![]]+(!![]+[])[+!![]]+(!![]+[])[+!![] + +!![]]+({}+[])[+!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![] + +!![] + +!![] + +!![] + +!![] + +!![]]+({}+[])[+!![]]+(!![]+[])[+!![]]][(![]+[])[+[]]+(!![]+[])[+!![]]+({}+[])[+!![]]+(+!![] + +!![] + +!![] + +!![] + +!![] + +!![] + +!![] +
@eivl
eivl / Aura
Last active July 10, 2022 16:58
Elvui profiles
AV4xXlRedF5eOjpmaWx0ZXJz
Save New Duplicate & Edit Just Text Twitter
import pygame
import pygame.locals
import random
import win32api
import win32gui
import win32con
from win32api import GetSystemMetrics
from win32con import SWP_NOMOVE

Keybase proof

I hereby claim:

  • I am eivl on github.
  • I am eivl (https://keybase.io/eivl) on keybase.
  • I have a public key ASDY2ZfI3BhoaOuiKdZ22M5cdM1bd9INGViAnW3YV95Yrgo

To claim this, I am signing this object:

@eivl
eivl / fncache.py
Created October 11, 2019 22:01 — forked from kwarrick/fncache.py
Redis-backed LRU cache decorator in Python.
#!/usr/bin/env python
__author__ = 'Kevin Warrick'
__email__ = 'kwarrick@uga.edu'
import cPickle
from functools import wraps
def redis_lru(capacity=5000, slice=slice(None)):
"""
Simple Redis-based LRU cache decorator *.
import random
def quick_sort(list_of_numbers):
if len(list_of_numbers) <= 1:
return list_of_numbers
pivot = random.choice(list_of_numbers)
less_then = [n for n in list_of_numbers if n < pivot]
equal = [n for n in list_of_numbers if n == pivot]
greater_then = [n for n in list_of_numbers if n > pivot]