Skip to content

Instantly share code, notes, and snippets.

@ScriptRaccoon
ScriptRaccoon / pwgen
Created March 27, 2025 09:44
Password generator CLI (with Python)
#!/usr/bin/env python3
# This Python script can quickly generate passwords.
# Simply type 'pwgen' into the terminal.
# Options:
# -l or --length to set the length. Default is 20.
# -a or --alphanumeric to generate an alphanumeric password: no special characters.
import argparse
import random
@ScriptRaccoon
ScriptRaccoon / index.ts
Last active March 13, 2025 13:42
zod example
import { z } from "zod"
// USER
const userNameSchema = z
.string({
invalid_type_error: "Username must be a string",
required_error: "Username is required",
})
.min(2, { message: "Username must be at least 2 characters long" })
@ScriptRaccoon
ScriptRaccoon / dailybot.gs
Last active January 25, 2025 18:20
Script for a slack app sending a daily bot message thatannounces the Daily animator
const scriptProperties = PropertiesService.getScriptProperties()
const WEBHOOK_URL = scriptProperties.getProperty('WEBHOOK_URL')
const COLLEAGUES = [
{
name: 'Hanna',
slackID: '...',
},
{
name: 'Martin',
@ScriptRaccoon
ScriptRaccoon / rubik.py
Last active September 29, 2024 20:18
Verifies that 1260 is the highest possible order of an element in the 3x3 Rubik's cube group
"""
This module verifies that 1260 is the highest possible order of an element in the 3x3 Rubik's cube group.
This is only an upper bound but it turns out that it can also be achieved, so this estimate is precise.
The approach is loosely based on the answer by 'jmerry' at https://math.stackexchange.com/questions/2392906/
"""
from functools import lru_cache
import math
@ScriptRaccoon
ScriptRaccoon / subtitle-generator.py
Created April 27, 2024 21:12
script generating numbered timestamps based on clicks
import time
# This script generates numbered timestamps based on clicks
# This has been used for example in https://youtu.be/4t61xW8QIEg
def main():
print("Click whenever you want to mark a timestamp")
print("Press 'q' to quit and generate timestamps\n")
@ScriptRaccoon
ScriptRaccoon / script.gs
Created February 12, 2024 22:15
Google Apps Script to sync from Spreadsheet to Calendar
/*
This script needs to be bound with a Google Spreadsheet.
It needs to have a header row of the form: title | start | end | description
The script then generates calendar entries for every row below.
For example, the sheet could have the following entries (displayed in csv format):
Title,Start,End,Description
Test 1,27.02.2024 11:00:00,27.02.2024 15:00:00,Hallo 1
Test 2,28.02.2024 15:00:00,28.02.2024 17:30:00,Hallo 2
@ScriptRaccoon
ScriptRaccoon / script.js
Last active January 27, 2024 12:00
Add MIT licenses to all your repos
const TOKEN = "...." // your github access token
const owner = "..." // your github name
const blackList = [] // the names of the repos you don't want to process
const { Octokit } = require("@octokit/rest") // install this first
const octokit = new Octokit({ auth: TOKEN })
const fs = require("fs")
@ScriptRaccoon
ScriptRaccoon / open-discussions.js
Last active October 17, 2023 10:53
Script to open all GitHub discussions in a PR. Continuously clicks on the "Load More" buttons.
const loadmore_condition = (button) => button.innerText.includes('Load more');
const status_element = document.createElement('div');
status_element.innerText = 'Opening conversations ...';
status_element.style =
'position: fixed; z-index: 100; top: 1rem; left: 1rem; background-color: white; color: black; border: 1px solid black; padding: 0.5rem 1rem;';
document.body.appendChild(status_element);
async function open_conversations() {
@ScriptRaccoon
ScriptRaccoon / calendar-script.gs
Last active August 12, 2023 07:50
Google Apps Script that copies Google calendar entries to a Google sheet
/*
This Google script needs to be added to a Google spreadsheet.
It lists all calendar entries within one year (that time range is configurable)
and adds them to the first sheet in the spreadsheet. The script also adds
a button 'Update' in the spreadsheet's UI that executes the main update function.
*/
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const sheet = spreadsheet.getSheets()[0];
@ScriptRaccoon
ScriptRaccoon / tuple-type.ts
Created July 7, 2023 11:52
Tuple types in TypeScript with fixed length
type Tuple<Length extends number, T, Accumulator extends T[] = []> =
Accumulator["length"] extends Length ?
Accumulator :
Tuple<Length,T,[...Accumulator,T]>;
const example: Tuple<3,string> = ["hi","mom","!"];