This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // return true iff player 1 has a winning strategy for n-size treblecross | |
| // https://en.wikipedia.org/wiki/Treblecross | |
| function treblecross_win_optimized(n: number): boolean { | |
| if (n === 0 || n === 2) return false | |
| if (n === 1) return true | |
| if (n >= 32) throw new Error("We use bitmasks, only n <= 32 allowed.") // FIXME | |
| const cache: Map<number, boolean> = new Map() | |
| let board = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Creates a proxy of an object that prevents the access to selected properties | |
| */ | |
| function secure<T extends Record<PropertyKey, unknown>, K extends readonly (keyof T)[]>( | |
| obj: T, | |
| fields: K, | |
| ): Omit<T, K[number]> { | |
| return new Proxy(obj, { | |
| get(target: T, property: PropertyKey, receiver: any) { | |
| if (fields.includes(property)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Use this script on https://www.last.fm/user/{your_user_name}/loved | |
| * to remove all your loved songs on last.fm. | |
| */ | |
| function click_unlike_button() { | |
| const button = document.querySelector('.chartlist-love-button') | |
| if (!button) { | |
| const next_page_link = document.querySelector('.pagination-next a') | |
| if (!next_page_link) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const scriptProperties = PropertiesService.getScriptProperties() | |
| const WEBHOOK_URL = scriptProperties.getProperty('WEBHOOK_URL') | |
| const COLLEAGUES = [ | |
| { | |
| name: 'Hanna', | |
| slackID: '...', | |
| }, | |
| { | |
| name: 'Martin', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
NewerOlder