Skip to content

Instantly share code, notes, and snippets.

View ydlamba's full-sized avatar

Yash Dev Lamba ydlamba

View GitHub Profile
@greed2411
greed2411 / profile_malloc.py
Last active November 7, 2023 06:26
finding memory allocations (and memory leak) in python source code, how many times, size in bytes with tracemalloc
"""
Python script to find the memory allocations
i. over a module/function that is running
ii. between the loops
It is a script so that it can be torn apart for your own use-cases.
Based on this nice article on trying to find memory leaks in python:
https://www.fugue.co/blog/diagnosing-and-fixing-memory-leaks-in-python.html
But the code is non-existent and isn't reproducible as of 2023.
@leommoore
leommoore / file_magic_numbers.md
Last active May 7, 2024 20:49
File Magic Numbers

File Magic Numbers

Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.

For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.

This gives an ongoing list of file-type magic numbers.

Image Files