Skip to content

Instantly share code, notes, and snippets.

View yashbhutoria's full-sized avatar
👨‍💻
Making things happen

Yash Bhutoria yashbhutoria

👨‍💻
Making things happen
View GitHub Profile
@yashbhutoria
yashbhutoria / decorator_example.py
Last active March 14, 2019 13:39
Decorator with arguments in Python3
def decorator(param_passed = None):
def real_dec(func):
def inner(a,b):
if param_passed:
print(f'Param Passed is {param_passed}')
print(f'Performing {func.__name__} on {a} and {b}')
return func(a,b)
return inner
return real_dec
@yashbhutoria
yashbhutoria / complex_decorator_example.py
Created March 14, 2019 13:41
Single decorator with two functions in it
def decorator(param_passed = None):
def real_dec(func):
#on passing 0
def inner_1(a,b):
print(f'Performing {func.__name__} on {a} and {b} with First Decoration')
return func(a,b)
#on passing 1
def inner_2(a,b):
@yashbhutoria
yashbhutoria / WindowsTerminalMonokai.json
Created May 25, 2019 07:07
Base16 based Monokai theme for Windows Terminal
{
"name": "Monokai",
"foreground": "#FF7CBB",
"background": "#272822",
"colors": [
"#272822",
"#F92672",
"#A6E22E",
"#F4BF75",
"#66D9EF",
@yashbhutoria
yashbhutoria / AboutMe.png
Last active June 23, 2019 10:31
About Me !
AboutMe.png
@yashbhutoria
yashbhutoria / CurriculumVitae.png
Last active July 17, 2020 23:55
Curriculum Vitae
CurriculumVitae.png
@yashbhutoria
yashbhutoria / extract_7z_to_bytes.py
Last active November 25, 2019 06:13
Extract 7z to bytes in memory using libarchive. In your case, you might be pulling it from a cloud storage and don't wan't to write in your secondary memory.
import libarchive.public #Not Secure?
# Reading the archived 7z file as bytes
with open('csvarchive.7z','rb') as f:
archive_bytes = f.read()
# The function that you might want to use
def archive_bytes_to_file_bytes(archive_bytes):
global entry_var
with libarchive.public.memory_reader(archive_bytes) as reader: