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
import pathlib | |
import zipfile | |
main_dir = r"folder_with_a_bunch_of_zips" | |
# extract a zip file windows | |
def extract_zip(zip_file): | |
with zipfile.ZipFile(zip_file, 'r') as zip_ref: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import matplotlib.pyplot as plt | |
import numpy as np | |
def get_f_df(c: list[int]) -> tuple[callable, callable]: | |
""" Get the function and its derivative for a given polynomial c""" | |
def f(z): | |
ans = 0 | |
for i, c_i in enumerate(c): |
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
# I ran on python 3.12 | |
# requires `pip install matplotlib numpy` | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def get_f_df(c: list[int]) -> tuple[callable, callable]: | |
""" Get the function and its derivative for a given polynomial c""" | |
def f(z): |
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
import datetime as dt | |
from sqlalchemy import create_engine, Column, DateTime, Integer, String | |
from sqlalchemy.orm import declarative_base, sessionmaker | |
Base = declarative_base() | |
class TZTest(Base): | |
__tablename__ = 'tztest' | |
id = Column(Integer, primary_key=True) | |
timestamp_no_tz = Column(DateTime) |
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
import timeit | |
TOKEN = b"super_secret_token" | |
# Which one is better? | |
def is_authorized_one(provided_token: bytes, expected_token: bytes) -> bool: | |
return provided_token == expected_token | |
def is_authorized_two(provided_token: bytes, expected_token: bytes) -> bool: |
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
@echo off | |
doskey gsu=git status -uno | |
doskey gs=git status | |
doskey gpr=git pull -r | |
doskey gf=git fetch | |
doskey gc=git commit $* | |
doskey ga=git add $* | |
doskey gch=git checkout $* | |
doskey gka=gitk --all | |
set PATH=%PATH%;"c:\dev\ag" |
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
""" A way to test columns with auto_now | |
Columns with auto_now auto update with the current time when | |
the model is saved - this patches function django uses to | |
get the current time when the model is saved to use whatever | |
time you want. | |
Base on answers on SO: https://stackoverflow.com/questions/49874923/how-to-test-auto-now-add-in-django | |
""" | |
from contextlib import contextmanager |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder