Skip to content

Instantly share code, notes, and snippets.

View mnarayan's full-sized avatar

mnarayan mnarayan

View GitHub Profile
# Make sure to add your SSH key to your RunPod account
echo "export HF_HOME=/workspace/hf_home/" >> ~/.bashrc
apt-get update
apt-get upgrade -y
apt-get install -y sudo git vim ssh net-tools htop curl zip unzip tmux rsync libopenmpi-dev iputils-ping make fzf restic ripgrep wget pandoc poppler-utils pigz bzip2 nano locales
pip install uv
# Alternative: curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system --compile-bytecode ipykernel kaleido nbformat numpy scipy scikit-learn scikit-image transformers datasets torchvision pandas matplotlib seaborn plotly jaxtyping einops tqdm ruff basedpyright umap-learn ipywidgets virtualenv pytest git+https://github.com/callummcdougall/eindex.git transformer_lens nnsight
apt-get install -y libnss3 libatk-bridge2.0-0 libcups2 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2
# Optional:
@jamestwebber
jamestwebber / numba_mannwhitney.py
Last active August 21, 2023 16:39
numba-fied, parallelized Mann-Whitney U-test for 2d arrays
import numpy as np
import numba as nb
import scipy.stats
@nb.njit(parallel=True)
def tiecorrect(rankvals):
"""
parallelized version of scipy.stats.tiecorrect
@neurojojo
neurojojo / betterfigures.py
Created July 31, 2020 02:29
Create readable figures in Python
import matplotlib.pyplot as plt
x=[-2,-1,0,1,2]; y=[4,1,0,1,4]
# Set DPI >=150 for readability and adjust figsize
myfig = plt.figure( figsize=(3,1.5), dpi=150 )
# Pick a nice color, make sure your markers are large and
# make sure your lines are wide
myplt = plt.plot( x, y, 'o', color = 'c', markersize=6)
plt.plot( x, y, color= 'c', linewidth=2)
@martinsotir
martinsotir / google_ai_notebooks_tips.md
Last active July 8, 2023 13:29
Google AI notebook tips

Google AI Platform Notebook tips

AI Notebooks vs Colab

Google Colab: https://colab.research.google.com/

  • Free compute! and interesting, fixed cost, 10$/month Google Colab Pro version.
  • Notebooks are very easy to share, with ability to control permissions (integration in google drive/doc ecosystem).
  • Instant availability. No requirement other than a regular google account.
  • Idle time limit : 1h in free version.
@amalmurali47
amalmurali47 / README.md
Created May 1, 2019 18:31
Delete all Telegram contacts.

How to delete all your Telegram contacts at once?

  1. Go to https://web.telegram.org and sign in if you're not already signed in.
  2. On the top-left, click on the hamburger icon to show the dropdown menu, and choose "Contacts" from the list.
  3. Choose "Edit".
  4. Open the Developer Console of your browser (preferably Chrome or Firefox). On Chrome, that is Ctrl + Shift + J.
  5. Run the following JS snippet:
var x = document.getElementsByClassName('contacts_modal_contact')
@pmelchior
pmelchior / pytorch_pgm.py
Created December 30, 2018 23:23
Proximal Gradient Method for pytorch (minimal extension of pytorch.optim.SGD)
from torch.optim.sgd import SGD
from torch.optim.optimizer import required
class PGM(SGD):
def __init__(self, params, proxs, lr=required, momentum=0, dampening=0,
nesterov=False):
kwargs = dict(lr=lr, momentum=momentum, dampening=dampening, weight_decay=0, nesterov=nesterov)
super().__init__(params, **kwargs)
if len(proxs) != len(self.param_groups):
raise ValueError("Invalid length of argument proxs: {} instead of {}".format(len(proxs), len(self.param_groups)))
# install.packages(c("devtools", "tidyverse"))
# devtools::install_github("malcolmbarrett/ggdag")
library(ggdag)
library(tidyverse)
dag <- dagify(D ~ ABU1 + AEU2 + BEU3,
ABU1 ~ A + B + U1,
AEU2 ~ A + E + U2,
BEU3 ~ B + E + U3)
@oesteban
oesteban / fmriprep.sbatch
Last active April 6, 2024 19:52
Submitting many FMRIPREP/MRIQC tasks in Sherlock
#!/bin/bash
#
#SBATCH -J fmriprep
#SBATCH --array=1-257%7
#SBATCH --time=24:00:00
#SBATCH -n 1
#SBATCH --cpus-per-task=16
#SBATCH --mem-per-cpu=4G
#SBATCH -p russpold,owners,normal
@Svidro
Svidro / !Making Measurements in QuPath
Last active November 21, 2025 18:32
Making Measurements in QuPath
Collections of scripts harvested mainly from Pete, but also picked up from the forums
TOC
Accessing dynamic measurements.groovy - Most annotation measurements are dynamically created when you click on the annotation, and
are not accessible through the standard getMeasurement function. This is a way around that.
Affine transformation.groovy - access more accurate measurements for the affine transformation used in the image alignment (m5/m6+)
Alignment of local cells.groovy - check neighborhood for similarly aligned cells
@theHausdorffMetric
theHausdorffMetric / margintale_blog_3.R
Created January 21, 2018 17:38
tidyverse time series heatmaps
# An simple function to turn an xts time series
# into a ggplot calendar heatmap
require(tidyverse)
# The core idea is to transform the data such that one can
# plot "Value" as a function of "WeekOfMonth" versus "DayOfWeek"
# and facet this Year versus Month
xts_heatmap <- function(x){
data.frame(Date=as.Date(index(x)), x[,1]) %>%