Skip to content

Instantly share code, notes, and snippets.

View Pangoraw's full-sized avatar
🔧
tuning

Paul Berg Pangoraw

🔧
tuning
View GitHub Profile
import math
class ZeroToOneBinner:
def __init__(self):
self.bins = 8
self.counts = [0 for _ in range(self.bins)]
self.total = 0
def update(self, values):
@Pangoraw
Pangoraw / readme.md
Last active February 14, 2023 08:54
Firefox compact mode

Go to about:config Search for compactmode, toggle to true

for seo:

  • window control merge into tab bar;
@Pangoraw
Pangoraw / pdf_zotero.sh
Last active January 24, 2023 13:05
Open zotero files from a selector like rofi, dmenu, fzf,...
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
ZOTERO_DIR="$HOME/snap/zotero-snap/common/Zotero"
ZOTERO_DB="${ZOTERO_DIR}/zotero.sqlite"
PDF_READER="$HOME/Projects/piz/target/debug/piz"
@Pangoraw
Pangoraw / Wild story recording.html
Created December 1, 2022 22:43
openai whisper in pluto
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<meta charset="utf-8" />
<meta name="pluto-insertion-spot-meta">
@Pangoraw
Pangoraw / cocw_to_coco.py
Last active October 17, 2022 11:40
COCW to COCO converter
import os
from pathlib import Path
import json
import argparse
from PIL import Image
import numpy as np
# import detectron2
# from detectron2.structures import BoxMode
@Pangoraw
Pangoraw / 0001-Allow-using-the-CPU-for-txt2img.patch
Last active August 29, 2022 14:29
Stable diffusion txt2img using the CPU
From 4e32b5ebfc3bb54cabf192488e43e768781eeafb Mon Sep 17 00:00:00 2001
From: Paul Berg <paul.berg@univ-ubs.fr>
Date: Mon, 29 Aug 2022 16:28:55 +0200
Subject: [PATCH] Allow using the CPU for txt2img
---
configs/stable-diffusion/v1-inference.yaml | 2 ++
scripts/txt2img.py | 18 ++++++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
from pathlib import Path
import pickle
import functools
import hashlib
def hash_args(args, kwargs):
assert all(isinstance(s, str) for s in kwargs.values())
assert all(isinstance(s, str) for s in args)
import torch
from torch import Tensor
def batch_sinkhorn(
a: Tensor,
b: Tensor,
C: Tensor,
reg: float,
max_iters: int = 10,
@Pangoraw
Pangoraw / fix_slide_controls.jl
Last active June 6, 2023 17:03
Fix the broken slide controls in Pluto (0.19.? <= x <= 0.19.9)
# ╔═╡ 9e5d37c8-c45c-4eb0-bc38-fd42bb408508
html"""
<script>
const calculate_slide_positions = (/** @type {Event} */ e) => {
const notebook_node = /** @type {HTMLElement?} */ (e.target)?.closest("pluto-editor")?.querySelector("pluto-notebook")
console.log(e.target)
if (!notebook_node) return []
const height = window.innerHeight
const headers = Array.from(notebook_node.querySelectorAll("pluto-output h1, pluto-output h2"))
@Pangoraw
Pangoraw / kappa.py
Created June 15, 2022 09:25
Online Cohen Kappa coefficient
from typing import Dict, Tuple
import torch
from torch import Tensor
class OnlineKappa:
"""
Computes an online version of the Cohen's Kappa Coefficient.