Skip to content

Instantly share code, notes, and snippets.

@promovicz
promovicz / evolution.pari
Last active November 26, 2023 21:31
Mathematical evolution experiment in PARI/GP
\\ An Evolution Game
\\
\\ Implemented by @promovicz on 2023-11-25.
\\
\\ Inspired by Martin Escardo on Mastodon:
\\ https://mathstodon.xyz/@MartinEscardo/111467732542708261
\\
\\ Count derangements in world $x$
derangements(x) = sum(i=1,#x,x[i]!=i)
@promovicz
promovicz / compact-profile.css
Last active December 23, 2022 22:11
Mastodon 4: overlay CSS for a much more compact profile table
.account__header__fields {
padding: 0.2em 0.3em;
}
.account__header__fields dl {
width: 100%;
overflow: hidden;
padding: 0.1em;
margin: 0
}
.account__header__fields dl dt {
@promovicz
promovicz / mastodon.css
Last active November 19, 2022 23:26
Mastodon 4: UI customizations
/* Hide navigation bar logo */
.navigation-panel__logo {
display: none;
}
/* Hide header logo */
.ui__header__logo svg {
display: none;
}
/* Toot button */
.ui__header__links > .button[href="/publish"],
@promovicz
promovicz / unsuspend-users.py
Last active November 16, 2022 14:07
Mastodon: script that unsuspends all users given on the command line
#!/usr/bin/python3
# spontaneously smashed together by @[email protected]
# in response to a question by @[email protected]
from argparse import ArgumentParser
from mastodon import Mastodon
ap = ArgumentParser('unsuspend')
ap.add_argument('-i',type=str,help='instance',default='chaos.social')
@promovicz
promovicz / allmem.c
Created July 7, 2022 17:06
Automatically map unmapped memory
// This little program uses a SIGSEGV handler to auto-map pages as they are used.
// If you want you can use this to program without a memory allocator.
// gcc -std=c11 -Wall -Wextra -g -o allmem allmem.c /usr/lib/x86_64-linux-gnu/libsigsegv.a
#define _GNU_SOURCE 1
#include <stddef.h>
#include <stdint.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
@promovicz
promovicz / README.txt
Last active November 16, 2021 03:07
Enhanced dmenu for use with qubes and i3
Example use:
# qubes control
bindsym $mod+u exec --no-startup-id "qubes-i3-dmenu-shell --start"
bindsym $mod+Shift+u exec --no-startup-id "qubes-i3-dmenu-shell --pause"
bindsym $mod+i exec --no-startup-id "qubes-i3-dmenu-shell --shutdown"
bindsym $mod+Shift+i exec --no-startup-id "qubes-i3-dmenu-shell --unpause"
# qubes launching
bindsym $mod+o exec --no-startup-id "qubes-i3-dmenu-shell --global"
@promovicz
promovicz / bin2brl.c
Created November 7, 2020 21:53
Converting binary data into Unicode Braille
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <unistd.h>
int main(int argc, char **argv) {
int res, i;
char buf[64];
@promovicz
promovicz / qvm-restart
Created October 25, 2020 10:21
Qubes domain restart script
#!/bin/sh
# qvm-restart <domain>
#
# Restart the given Qubes DOMAIN, reattaching
# all its network dependents as needed.
#
set -e
@promovicz
promovicz / qubes.GetHostsFile
Last active October 24, 2020 19:32
Qubes RPC service generating a hosts file for a firewall VM
#!/bin/bash
# qubes.GetHostsFile - RPC service for retrieving a hosts file
#
# This will emit a hosts file containing the addresses of all qubes
# directly connected to the qube calling the service.
#
# It can be used in firewall VMs to get name resolution for these VMs.
#
# Note that using this script might create an information leak.
@promovicz
promovicz / popcount.c
Created June 20, 2019 02:14
Counting bits with a compiler builtin
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
unsigned word;
int count;
/* check for argument */
if(argc < 2) { printf("Usage: %s INTEGER\n", argv[0]); abort(); }
/* convert argument */
word = (unsigned)atoi(argv[1]);
/* count number of 1-bits */