Skip to content

Instantly share code, notes, and snippets.

View Thesola10's full-sized avatar
🐢
slow day

Karim Vergnes Thesola10

🐢
slow day
View GitHub Profile
@Thesola10
Thesola10 / parse-ostree-staged.py
Created November 12, 2024 20:09
Parse metadata for staged OSTree deployment
#!/usr/bin/env python3
# Parse metadata for staged OSTree deployment
# (c) Karim Vergnes <[email protected]>
import json
from gi.repository import GLib
VARIANT_TYPE = GLib.VariantType("a{sv}")
@Thesola10
Thesola10 / sprinkle.py
Created December 1, 2022 10:53
random data at random places
#!/usr/bin/env python3
"""Sprinkle - Write random data at random places
Usage:
sprinkle.py <file> [--size=<size>] [--safe-start=<start>] [--safe-end=<end>] [--once]
Options:
-h --help Show this message and exit.
--version Show version.
@Thesola10
Thesola10 / nixos-spawn.sh
Last active June 22, 2024 16:06
Build and spin up a NixOS configuration or flake as a systemd-nspawn container on non-NixOS systems.
#!/bin/sh
# nixos-spawn (c) Karim Vergnes <[email protected]>
# This script launches systemd-nspawn in an empty root, with an overlay of the
# host's Nix Store. This takes advantage of the NixOS stage 2 init's ability to
# populate an empty system automatically.
# By default, no changes are persisted anywhere -- use an additional bind mount
# to add permanent storage.
: ${NIXOS_CHANNEL:=nixpkgs}
@Thesola10
Thesola10 / reboot.sh
Last active March 22, 2022 09:53
Reboot to an arbitrary UEFI entry
#!/bin/bash
# Reboot-EFI (c) Karim Vergnes <[email protected]>
# Wrapper to reboot to a set UEFI entry
# Requires efibootmgr and fzy
rebootcmd="shutdown -r now"
trap _exit KILL INT TERM
_exit() {
@Thesola10
Thesola10 / bwrap-nix.sh
Last active June 4, 2023 20:22
It's Nix in a Box!
#!/bin/sh
# bwrap-nix (c) Karim Vergnes <[email protected]>
# It's Nix in a Box! (useful for an unprivileged Nix environment)
if [[ $# < 2 ]]
then
>&2 echo "usage: $0 <nix directory> <command> [args]..."
exit 1
fi
@Thesola10
Thesola10 / francais.h
Last active November 12, 2021 14:40
Vous aussi, programmez en fran-C !
#define vide void
#define si if
#define sinon else
#define retourner return
#define pour for
#define tantque while
#define faire do
#define booleen bool
#define entier int
#define caractere char
@Thesola10
Thesola10 / lib.mk
Created May 30, 2021 13:25
Useful resources for pretty makefiles.
GREEN := $(shell tput setaf 2 2>/dev/null)
YELLOW := $(shell tput setaf 3 2>/dev/null)
BOLD := $(shell tput bold 2>/dev/null)
RESET := $(shell tput sgr0 2>/dev/null)
define rich_echo
printf "${BOLD}$(1)${RESET}\t$(2)\n"
endef
@Thesola10
Thesola10 / mk302.py
Created May 18, 2021 17:38
Generate a static redirect page. Can be useful on IPFS for link shortening for instance.
#!/usr/bin/env python3
# mk302 by Karim Vergnes <[email protected]>
# License: CC0 1.0 Universal
# Requires Jinja2
'''<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="REFRESH" content="0;url={{ href }}"" />
<script>window.location.href="{{ href }}"</script>
@Thesola10
Thesola10 / duckduckgo.user.css
Last active April 3, 2024 14:01
Replaces the default DuckDuckGo icon with Virtual Youtuber Oozora Subaru from Hololive.
/* ==UserStyle==
@name DuckDuckGo Oozora Subaru Edition
@namespace thesola10
@version 1.0.0
@license MIT
@updateURL https://gist.githubusercontent.com/Thesola10/a7cbfd9cc7c7b8a697a0c08472d06b98/raw/duckduckgo.user.css
@author thesola10
==/UserStyle== */
@-moz-document domain("duckduckgo.com") {
@Thesola10
Thesola10 / pixbat.py
Last active January 26, 2022 07:10
Wrapper around bat and pixcat to display images in the bat command
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This script is designed to be installed in ~/.local/bin/bat or equivalent
from os import execvp
import sys
import subprocess
if __name__ == "__main__":
try: