Skip to content

Instantly share code, notes, and snippets.

View Magnus167's full-sized avatar
🧘
thinking...

Palash Tyagi Magnus167

🧘
thinking...
View GitHub Profile

NOTICE:

TLDR : Not my original work, I copied it over as I needed it to be in markdown formatting.

This is not my own content, and is merely curated here for accessibilty and sharing. The below article has been copied from https://www.joelsleppy.com/blog/gunicorn-application-preloading/, with all rights to intellectual property reserved by the authors/domain-owners.

Gunicorn Application Preloading

@Magnus167
Magnus167 / random.fact.md
Created February 20, 2023 22:51
interesting things about the world : the average CPU dissipates many orders of magnitude more heat per unit mass than the sun

An i9/i7 CPU uses about 150W (watts) of power. Which means that it somehow "dissipates" that much energy, mostly heat. Let's say it dissipates 120W as heat, which is a fair estimate.

Let's say the CPU weights about 60g = 0.06kg. That means that the CPU dissipates :

120W/0.06kg = 2000W/kg of heat.

For argument's sake let's say this is some new age alien tech that only dissipates 1 W as heat. That would imply our CPU dissipates :

1W/0.06kg = 16.7W/kg of heat.

@Magnus167
Magnus167 / treemaps.ipynb
Created January 16, 2023 16:51
tree maps for pydirstats
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Magnus167
Magnus167 / multi-handlers-logger.py
Created December 15, 2022 17:48 — forked from nguyendv/multi-handlers-logger.py
Python logger with multiple handlers (stream, file, etc.), so you can write log to multiple targets at once
import logging
from logging.handlers import RotatingFileHandler
def setup_logger():
MAX_BYTES = 10000000 # Maximum size for a log file
BACKUP_COUNT = 9 # Maximum number of old log files
# The name should be unique, so you can get in in other places
# by calling `logger = logging.getLogger('com.dvnguyen.logger.example')
logger = logging.getLogger('com.dvnguyen.logger.example')
@Magnus167
Magnus167 / pandas_df_zise.py
Last active January 26, 2023 16:24
printing memory used/size in bytes of a pandas dataframe
import pandas as pd
from typing import *
df : pandas.Dataframe = some_stuff()
print(f"Size of dataframe: {df.memory_usage().sum() / 1024**2:.2f} MB")
@Magnus167
Magnus167 / import_from_parent.py
Last active January 26, 2023 16:22
Trix to import a python module sitting in the parent folder
import sys
sys.path.append('../')
import somePackage
from otherPackage import moduleX
# - base_folder/
# - - dev/
# - - - > this_file.py
@Magnus167
Magnus167 / python_truth_values_of_objects.py
Created October 28, 2022 09:54
Python: Truth values of the several different types of Python objects.
from math import floor
t = [ 0 ,
10000 ,
10/100 ,
floor(10/100) ,
[] ,
[1] ,
{} ,
{"a":1},
'',
@Magnus167
Magnus167 / 01-explanation-of-python-logging-and-the-root-logger.md
Created October 24, 2022 15:50 — forked from gene1wood/01-explanation-of-python-logging-and-the-root-logger.md
Explanation of the relationship between python logging root logger and other loggers

Explanation of the relationship between python logging root logger and other loggers

@Magnus167
Magnus167 / mongo_db_startup_guide.ipynb
Created October 24, 2022 14:54
This is a quick start guide for using and running MongoDB. Has some very basic examples included.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Magnus167
Magnus167 / custom_logging_with_decorators.py
Created October 18, 2022 16:48
Demonstrates how to use a decorator to allow a logger to track a set of processes using a key; sample output included.
import logging, sys, uuid
# pip install logging_tree
import logging_tree
import functools
from time import sleep
############################################################################################################
# Some wierd calculations; don't read into them