Skip to content

Instantly share code, notes, and snippets.

@Bondrake
Bondrake / translate-unicode-nf.py
Created April 20, 2024 01:16
This script will update all the Unicode codepoints in json/yaml/toml files to point to new Nerd Font icon locations
import os
import sys
def unicode_to_surrogate_pair(codepoint):
# Convert a Unicode codepoint to a surrogate pair if necessary
code = int(codepoint, 16)
if code <= 0xFFFF:
return f"\\u{codepoint.lower()}"
# Calculation for surrogate pairs
code -= 0x10000
@Bondrake
Bondrake / trim-generations.sh
Last active February 29, 2024 01:10
NixOS script to keep 10 generations or 7 days, whichever is more (configurable, profile is selectable)
#!/usr/bin/env bash
set -euo pipefail
## Defaults
keepGensDef=10; keepDaysDef=7
keepGens=$keepGensDef; keepDays=$keepDaysDef
## Usage
usage () {
printf "Usage:\n\t trim-generations.sh (defaults are: Keep-Gens=$keepGensDef Keep-Days=$keepDaysDef Profile=user)\n\n"
@Bondrake
Bondrake / pyteout.py
Last active December 20, 2015 21:48
Decode whitespace encoded gif
#!/usr/bin/env python2.7
string = ''
def decodeWhiteChar(char):
if char == '\t': # tab
value = '00'
elif char == '\r': # cr
value = '01'
elif char == '\n': # lf
class Player
attr_accessor :started, :firstkill
def play_turn(warrior)
if not @started
@started = true
warrior.pivot!
elsif warrior.look.select{|space| space.enemy?}.length > 0
warrior.shoot!
elsif warrior.look.select{|space| space.enemy?}.length == 0 and not @firstkill
@firstkill = true