Skip to content

Instantly share code, notes, and snippets.

View mnarayan's full-sized avatar

mnarayan mnarayan

View GitHub Profile
@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 May 1, 2024 09:16
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]) %>%
@GantMan
GantMan / NEW_OPENSOURCE_TODO.md
Last active December 27, 2021 23:20
ALL the things to do when starting a new Github Project - IR JavaScript | TypeScript

Step 1 - Create nest on Github

  1. Click Plus
  2. New Repository
  3. IR/REPO_NAME
  4. PROJECT_DESCRIPTION
  5. Do not initialize with anything (easier to add after)
  6. Star your repo
  7. Pull your repo down locally and cd to it