Skip to content

Instantly share code, notes, and snippets.

@phinate
phinate / custom.css
Created April 23, 2024 12:34 — forked from Ynng/custom.css
vscode vtuber logo
.editor-group-watermark > .letterpress{
background-image: url("https://raw.githubusercontent.com/Aikoyori/ProgrammingVTuberLogos/main/VSCode/VSCode-Thick.png") !important;
opacity: .75;
aspect-ratio: 3/2 !important;
}
@phinate
phinate / custom.css
Created April 23, 2024 12:34 — forked from Ynng/custom.css
vscode vtuber logo
.editor-group-watermark > .letterpress{
background-image: url("https://raw.githubusercontent.com/Aikoyori/ProgrammingVTuberLogos/main/VSCode/VSCode-Thick.png") !important;
opacity: .75;
aspect-ratio: 3/2 !important;
}
@phinate
phinate / era5.py
Created April 3, 2024 11:41
load slice of era5 for local use
import xarray
variables = [
'u_component_of_wind',
'v_component_of_wind',
'geopotential',
'temperature',
# ... full list of variables here: https://console.cloud.google.com/storage/browser/gcp-public-data-arco-era5/ar/1959-2022-full_37-1h-0p25deg-chunk-1.zarr-v2;tab=objects?pli=1&prefix=&forceOnObjectsSortingFiltering=false
]
@phinate
phinate / yield_prop.py
Last active August 8, 2023 17:11
three ways to propagate yields
import json
import pyhf
from pyhf.contrib.utils import download
import cabinetry
download("https://www.hepdata.net/record/resource/1935437?view=true", "bottom-squarks")
ws = pyhf.Workspace(json.load(open("bottom-squarks/RegionC/BkgOnly.json")))
patchset = pyhf.PatchSet(json.load(open("bottom-squarks/RegionC/patchset.json")))
ws = patchset.apply(ws, "sbottom_600_280_150")
cabinetry.workspace.save(ws, "bottom-squarks.json")
@phinate
phinate / example.py
Created August 2, 2023 14:25
pyhf-like models as pytrees
import jax.scipy as jsp
import equinox as eqx
import jax.numpy as jnp
from jax import Array
import jax
jax.config.update("jax_enable_x64", True)
@jax.jit
@phinate
phinate / sort_rc505_WAVE.py
Created March 10, 2023 14:56
sorts out the folders that the boss rc505 makes with more semantic names and better grouping based on a csv file
import polars as pl
import os
import shutil
q = (
pl.scan_csv("l.csv")
)
df = q.collect()
@phinate
phinate / pdf2svg.py
Created November 1, 2022 10:26
make svgs from pdfs with inkscape in python
import os
import glob
from re import sub
import subprocess
for fname in glob.glob("images/*.pdf"):
subprocess.run(
[
"inkscape",
"--pdf-poppler",
@phinate
phinate / jaxify_spec.py
Created July 1, 2022 14:39
convert a pyhf spec in-place to contain jax arrays
from __future__ import annotations
from jax import numpy as jnp
from typing import Any
def convert_jax(spec: dict[str, Any]) -> None:
for key, value in spec.items():
value_type = type(value)
if value_type == dict:
convert_jax(value)
@phinate
phinate / setup_cerngpu.sh
Last active October 15, 2021 13:13
quickstart for jupyter-compatible venv & github CLI
sudo apt-get update
sudo apt-get install python3.8-venv
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install ipykernel
sudo python -m ipykernel install --name="base"
echo "now in venv with jupyter kernel named base"
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null