Skip to content

Instantly share code, notes, and snippets.

View grenkoca's full-sized avatar

Caleb Grenko grenkoca

View GitHub Profile
@grenkoca
grenkoca / copy-fail-CVE-2026-31431__unminimized.py
Created April 29, 2026 23:47
CVE-2026-31431 (copy-fail) unminimized
#!/usr/bin/env python3
import os
import zlib
import socket
def d(x):
return bytes.fromhex(x)
import xml.etree.ElementTree as ET
from tifffile import TiffFile
import os
def extract_qptiff_biomarkers(file_path):
"""
Extract biomarker names from a QPTIFF file.
Parameters:
-----------
library(tidyr)
library(dplyr)
library(ggplot2)
data <- data.frame(
total_ligand_cpm = c(0, 12500, 25000, 50000, 100000, 175000, 250000, 400000, 900000),
bound_cpm_total = c(0, 480, 850, 1550, 2850, 4750, 5760, 7190, 9980),
bound_cpm_nonspecific = c(0, 50, 100, 200, 350, 650, 1200, 1900, 3600)
)
@grenkoca
grenkoca / ImportMeasurements.groovy
Last active April 15, 2025 22:39
QuPath Import and Update Cells
/**
* QuPath Script: Import External Measurements
*
* This script imports data from CSV/TSV files back into QuPath,
* allowing for integration of external analysis with QuPath objects.
*
* @author : Caleb Grenko
*/
guiscript=true
Presidency President Wikipedia Entry Took office Left office Party Portrait Thumbnail Home State
1 George Washington http://en.wikipedia.org/wiki/George_Washington 30/04/1789 4/03/1797 Independent GeorgeWashington.jpg thmb_GeorgeWashington.jpg Virginia
2 John Adams http://en.wikipedia.org/wiki/John_Adams 4/03/1797 4/03/1801 Federalist JohnAdams.jpg thmb_JohnAdams.jpg Massachusetts
3 Thomas Jefferson http://en.wikipedia.org/wiki/Thomas_Jefferson 4/03/1801 4/03/1809 Democratic-Republican Thomasjefferson.gif thmb_Thomasjefferson.gif Virginia
4 James Madison http://en.wikipedia.org/wiki/James_Madison 4/03/1809 4/03/1817 Democratic-Republican JamesMadison.gif thmb_JamesMadison.gif Virginia
5 James Monroe http://en.wikipedia.org/wiki/James_Monroe 4/03/1817 4/03/1825 Democratic-Republican JamesMonroe.gif thmb_JamesMonroe.gif Virginia
6 John Quincy Adams http://en.wikipedia.org/wiki/John_Quincy_Adams 4/03/1825 4/03/1829 Democratic-Republican/National Republican JohnQuincyAdams.gif thmb_JohnQuincyAdams.gif
@grenkoca
grenkoca / Optimal_K_Estimation.py
Created March 22, 2023 14:00
Estimate the optimal K for partitioning a dataset in python, as described in SC3 (Kiselev et al., 2017)
# See methods section of SC3 for details (Kiselev et al., 2017)
import numpy as np
import pandas as pd
from scipy.linalg import eigvalsh
import sys
def estkTW(dataset):
p = dataset.shape[1]
n = dataset.shape[0]
@grenkoca
grenkoca / Optimal_K_Estimation.R
Last active March 22, 2023 14:00
Estimate the optimal K for partitioning a dataset in R, as described in SC3 (Kiselev et al., 2017)
# See methods section of SC3 for details (Kiselev et al., 2017)
estkTW <- function(dataset) {
p <- ncol(dataset)
n <- nrow(dataset)
# compute Tracy-Widom bound
x <- scale(dataset)
muTW <- (sqrt(n - 1) + sqrt(p))^2
@grenkoca
grenkoca / high_ordinality_palette.py
Created November 2, 2022 13:37
A high ordinality color palette defined in hex code for matplotlib, seaborn, ggplot, or any other plotting software
COLORS_LARGE_PALLETE = [
'#0F4A9C', '#3F84AA', '#C9EBFB', '#8DB5CE', '#C594BF', '#DFCDE4',
'#B51D8D', '#6f347a', '#683612', '#B3793B', '#357A6F', '#989898',
'#CE778D', '#7F6874', '#E09D37', '#FACB12', '#2B6823', '#A0CC47',
'#77783C', '#EF4E22', '#AF1F26'
]
mkdir $HOME/bin
mkdir $HOME/lib
mkdir vips_tmp
cd vips_tmp
wget https://github.com/libvips/libvips/releases/download/v8.10.0-beta1/vips-8.10.0-beta1.tar.gz
tar -xzf vips-8.10.0-beta1.tar.gz
cd vips-8.10.0
./configure prefix=$HOME/
make
make install
@grenkoca
grenkoca / ExportMeasurements-2018.06.22-FB.groovy
Created June 22, 2018 19:52
Exports all cell measurements within selections to a csv file
import qupath.lib.gui.QuPathGUI
import qupath.lib.measurements.MeasurementList
import qupath.lib.scripting.QP
/**
* Exports detection results to excel file
*
* @Author Frank Bonini
* @Author Caleb Grenko (did admittedly little)
*/