Skip to content

Instantly share code, notes, and snippets.

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

Palash Tyagi Magnus167

🧘
thinking...
View GitHub Profile
@Magnus167
Magnus167 / get_pr_full.py
Last active March 26, 2024 09:28
Print list of PRs for a GitHub branch
import json
import urllib.request
import sys
import os
# get repo and branch from sys.argv
if len(sys.argv) < 3:
print("Usage: python getpr.py <repo> <branch>")
sys.exit(1)
@Magnus167
Magnus167 / pmerge.sh
Last active February 26, 2024 01:17
git pmerge - pull & merge. Use with Windows (powershell) or Unix-like alike
# Usage:
# git checkout featureX
# git pmerge main
# When merging branch `main` into `featureX`,
# one often has to pull from `main` to ensure
# merging into the correct head.
# Assume you're on branch featureX
# >> git pmerge main
# executes:
@Magnus167
Magnus167 / analyse_commit_info.py
Created February 6, 2024 17:31
Commit frequency plotter
# load commit_data.csv
from typing import List, Optional
import pandas as pd
df = pd.read_csv("commit_data.csv")
# filter where username is Palash Tyagi or Spalash
df = df[(df["username"] == "Palash Tyagi") | (df["username"] == "Spalash")]
@Magnus167
Magnus167 / 01_expl_monte_carlo_simulation.md
Last active November 22, 2023 16:43
What is a Monte Carlo simulation anyway?

In a nutshell, what is a Monte Carlo simulation anyway?

Monte Carlo simulations are typically used to get estimates of results, when the actual problem is too vast to be solved in entirety (or in a reasonable amount of time).

There are 3 examples, each closer to the real world version than the last. Example 1 is the best 😄

Example 1: Estimating the number of potholes in London

@Magnus167
Magnus167 / double_pend.py
Created August 10, 2023 14:13
Neat MPL script for a quick & dirty double pendulum calculation
# adapted from https://matplotlib.org/stable/gallery/animation/double_pendulum.html#sphx-glr-gallery-animation-double-pendulum-py
from numpy import sin, cos
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from collections import deque
G = 9.8 # acceleration due to gravity, in m/s^2
L1 = 1.0 # length of pendulum 1 in m
L2 = 1.0 # length of pendulum 2 in m
#include <stdio.h>
#include <string.h>
#define MAX 256
#define INT_BITS 32
void countingSort(int arr[], int n, int exp) {
int output[n]; // output array
int i, count[MAX] = {0};
@Magnus167
Magnus167 / dependencies.py
Created July 10, 2023 16:47
getting function level dependencies from a python package or a set of notebooks
"""
Scans Jupyter Notebooks for functions used from a given package.
The return
"""
from typing import List, Dict, Set, Tuple, Type, Callable
import ast
# import functools
import glob
import nbformat

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.