Skip to content

Instantly share code, notes, and snippets.

@nielsrolf
nielsrolf / setup.sh
Last active June 24, 2024 16:21
IMO worker setup
# Load .env
cd /workspace
sed -i '/^KVA_STORAGE=/d' .env
echo 'KVA_STORAGE=/workspace/kva_store' >> .env
export $(grep -v '^#' /workspace/.env | xargs)
echo "export $(grep -v '^#' /workspace/.env | xargs)" >> ~/.bashrc
# Github & Huggingface tokens
git config --global credential.helper store
echo "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com" > ~/.git-credentials
@nielsrolf
nielsrolf / music.py
Created January 23, 2024 06:21
Music metadata extractor for yt-dlp and offline music apps
import os
import shutil
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, TIT2, TPE1, TALB
import click
def update(file, directory, target_directory):
if file.endswith('.mp3'): # Check if the file is an MP3
path = os.path.join(directory, file)
@nielsrolf
nielsrolf / llm_reasoning_steps.py
Last active November 24, 2023 13:54
Generate riddles for LLMs
import random
def generate_riddle(n_hints, n_words, loop_length):
"""
Build a path towards the correct hint and fill the rest with random hints
"""
loop_length = loop_length - 1
assert n_words + loop_length < n_hints
values = list(range(n_words))
@nielsrolf
nielsrolf / deduplicate.py
Last active February 7, 2023 11:32
Image deduplication
import torch
import clip
from PIL import Image
import requests
from io import BytesIO
import click
import os
device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device)
@nielsrolf
nielsrolf / PolymarketAnalysis.ipynb
Created November 17, 2021 17:29
An analysis of the expected RoI of strategies that trade bets on polymarket.com, purely based on community likelihood estimations
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nielsrolf
nielsrolf / AlgorithmLearningByGradientDescent.ipynb
Created November 17, 2021 17:14
Neural networks for logical tasks, but the weights are probabilities for the effective weight to be either 1 or 0 in the forward pass
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<html>
<head>
<script>
window.onload = (() => {
/* Codex output here */
});
</script>
@nielsrolf
nielsrolf / siren-examples.ipynb
Created July 5, 2021 01:25
SIREN-Examples.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nielsrolf
nielsrolf / gradientgenerator.ipynb
Created June 18, 2021 19:59
GradientGenerator.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nielsrolf
nielsrolf / vscode.py
Created June 18, 2021 13:43
Colab VSCode workstation
"""
"
Poor man's ML workstation:
Recipe:
1. Auto-setup codeserver on colab
2. Auto-mount google drive and store editor settings and extensions directly on drive
3. Treat a drive folder as home directory
Result: