Skip to content

Instantly share code, notes, and snippets.

@farzadhallaji
farzadhallaji / zip_folder.py
Last active February 21, 2024 22:31
zip folder for myself
import zipfile
import tarfile
import os
def zip_folder(folder_path, zip_filename):
with zipfile.ZipFile(zip_filename, 'w') as zipf:
for foldername, subfolders, filenames in os.walk(folder_path):
for filename in filenames:
file_path = os.path.join(foldername, filename)
arcname = os.path.relpath(file_path, folder_path)

Enabling Access Time Logging and Identifying Unaccessed Files on Debian

Step 1: Check Current Mount Options

To check if access time logging is enabled, use the mount command:

mount | grep ' on / '
@farzadhallaji
farzadhallaji / crack-zip.py
Created July 25, 2024 12:20
Example for passwords starting with 'TOEFL' word
from time import sleep
import zipfile
import string
import itertools
from concurrent.futures import ProcessPoolExecutor, as_completed
# Define the path to the zip file and character set for passwords
zip_file_path = '/content/0.zip'
last_password_file = '/content/last_password.txt'
characters = string.ascii_uppercase
@farzadhallaji
farzadhallaji / df_to_latex.py
Created August 2, 2024 09:56
customizable function to covert pandas dataframe to latex
import pandas as pd
def df_to_latex(df, table_caption, table_label):
# Start building the LaTeX table string
latex_str = r"""
\renewcommand{\arraystretch}{1.5} % Adjust this value to change the row height
\begin{table}[h!]
\centering
\begin{adjustbox}{max width=\textwidth, center} % Fit table to page width and center it

1. Score Matching (SM)

Goal

Estimate the score: $s(x) = \nabla_x \log p(x)$

Why Not MLE?

MLE needs normalization: $\log p(x) = \log \tilde{p}(x) - \log Z$,
but $Z = \int \tilde{p}(x) dx$ is intractable.