Skip to content

Instantly share code, notes, and snippets.

View Grissess's full-sized avatar
🐲
busy doing derg things

Graham Northup Grissess

🐲
busy doing derg things
  • On your call stack
  • 01:58 (UTC -04:00)
View GitHub Profile
@Grissess
Grissess / iterators_iterables.ipynb
Created April 5, 2024 04:52
Iterators and Iterables
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
hosts = {}
for line in sys.stdin:
line = line.strip()
if not line:
continue
host, pkg = line.split()
hosts.setdefault(pkg, set())
@Grissess
Grissess / tri_puzzle.py
Created August 16, 2023 22:12
Solve those silly triangle tessellation puzzles with the colored pips
from enum import Enum
from dataclasses import dataclass
import time
Color = Enum('Color', ['K', 'W', 'R', 'Y', 'G', 'B'])
# Open them to this scope
for col in Color:
globals()[col.name] = col
RESET = '\x1b[m'
import argparse
MAP = {
'A': [' * ', ' * * ', '*****', '* *', '* *'],
'B': ['*** ', '* *', '*** ', '* *', '*** '],
'C': ['****', '* ', '* ', '* ', '****'],
'D': ['** ', '* * ', '* *', '* * ', '** '],
'E': ['****', '* ', '****', '* ', '****'],
'F': ['****', '* ', '*** ', '* ', '* '],
'G': ['*****', '* ', '* ***', '* *', '*****'],
@Grissess
Grissess / README.md
Created January 4, 2023 02:52
Streaming the screen [as a camera] under Wayland

Preparation

Before beginning, you will need:

  • v4l2loopback, a Linux kernel module that, like aloop, creates a loopback device that can be seen as a camera;
  • gstreamer, which can integrate with pipewire but doesn't seem to use v4l2loopback devices well;
  • ffmpeg, which does perfectly well with v4l2loopback but (for now) lacks pipewire support.

I'm presuming you're using pipewire and any of the xdg-desktop-portal implementations appropriate to your compositor, and that it is configured to be running as part of your session (and reachable via the DBus session bus).

@Grissess
Grissess / cpu.py
Last active July 3, 2022 21:47
WIP of an inane processor
import random
import os
import traceback
import sys
import ast
from random import randrange
from myhdl import block, always_comb, always_seq, always, \
Signal, ResetSignal, intbv, modbv, delay, instance, \
now, enum, bin
@Grissess
Grissess / check_disk.sh
Last active June 23, 2022 16:52
A little dialog wrapper for smartctl
#!/bin/bash
smartctl="${SMARTCTL:-smartctl}"
dialog="${DIALOG:-dialog}"
jq="${JQ:-jq}"
# Debian workaround
blockdev="${BLOCKDEV:-$(PATH="$PATH:/sbin:/usr/sbin" which blockdev)}"
sce_parse_bit=1
sce_open_bit=2
@Grissess
Grissess / en_US@grissess
Created February 14, 2022 01:21
A locale for Sunday-first calendars with ISO8601 time
# en_US, but with ISO8601 timestamps and 24-hour time,
# by Grissess.
# I, mentioned, claim no copyright in this work.
# Put this in your archive with:
# localdef -f UTF-8 -i en_US@grissess en_US.utf8@grissess
# (assuming you've installed everything according to the paths listed by
# localedef --help)
LC_IDENTIFICATION
@Grissess
Grissess / bom.py
Created November 6, 2020 17:03
MC Schematic to Bill of Materials
import nbt, sys
if len(sys.argv) > 1:
f = open(sys.argv[1], 'rb')
else:
f = sys.stdin
n = nbt.nbt.NBTFile(fileobj = f)
pal = {v.value: v.name.partition('[')[0] for v in n['Palette'].values()}
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>