Skip to content

Instantly share code, notes, and snippets.

View manncodes's full-sized avatar
💭
<think> ... </think>

Mann Patel manncodes

💭
<think> ... </think>
View GitHub Profile
import numpy as np
from typing import Tuple
def f0(a: float, b: float) -> float:
"""
Implements the formula:
f0(a,b) = (((a^4-1)^2-64)^2 - 2^7(1-(1-b^2)^2)^2) / 2^15
"""
a_term = (a**4 - 1)**2 - 64
a_term = a_term**2
@manncodes
manncodes / script.js
Last active April 27, 2024 09:26
data scrapper js script for extracting isin number from the site `https://www.isin.com/isin-database/`
// 1. login to https://www.isin.com/ and then head over to https://www.isin.com/isin-database/ page
// 2. open the chrome console by pressing F12, and paste the script inside the console.
// output: a json file named `all-data.json` containing list of dictionaries of info about the companies.
const org = ["nobiskrug", "swm", "vattenfall",
// and all the other companies you need to extract information about
];
function downloadJSON(data) {
const dataStr = JSON.stringify(data, null, 2);
const blob = new Blob([dataStr], { type: 'application/json' });
@manncodes
manncodes / fast-tensor-dataloader.py
Created September 12, 2022 17:52
20x speed up for tabular tensor data
import torch
class FastTensorDataLoader:
"""
A DataLoader-like object for a set of tensors that can be much faster than
TensorDataset + DataLoader because dataloader grabs individual indices of
the dataset and calls cat (slow).
Source: https://discuss.pytorch.org/t/dataloader-much-slower-than-manual-batching/27014/6
"""
def __init__(self, *tensors, batch_size=32, shuffle=False):
@manncodes
manncodes / plot.py
Created August 16, 2021 06:41
Dependency graph plotter
import os
import re
import argparse
import codecs
from collections import defaultdict
from graphviz import Digraph
include_regex = re.compile('#include\s+["<"](.*)[">]')
valid_headers = [['.h', '.hpp'], 'red']
valid_cuda = [['.cu'], 'green']

Semantic commit messages

See how a minor change to your commit message style can make you a better programmer.

  <type>[<scope>]: <short summary>
 │ │ │
@manncodes
manncodes / index.html
Created February 20, 2020 19:58
wvazRPb
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<div id="container">
<canvas id="game" width="100" height="100"></canvas>
</div>
<div id="controls">
<div id="buttons">
<button id="run" type="button">Start</button>
<button id="step" type="button">Step</button>
<button id="clear" type="button">Clear</button>