Skip to content

Instantly share code, notes, and snippets.

View mildsunrise's full-sized avatar
🦊
*rolls*

Alba Mendez mildsunrise

🦊
*rolls*
View GitHub Profile
@mildsunrise
mildsunrise / injectivity.agda
Last active March 27, 2023 09:22
proof that, for any function, existence of a left inverse ⇔ injectivity
open import Function using (Func)
open import Relation.Binary using (Setoid)
open import Relation.Nullary using (Dec; yes; no)
open import Data.Product using (_,_; ∃-syntax)
open import Level using (_⊔_)
import Relation.Binary.Reasoning.Setoid as Reasoning
open Setoid using (sym; refl)
open Func using (cong)
module injectivity
@mildsunrise
mildsunrise / README.md
Last active March 28, 2023 10:02
documentación sobre los OIDs de la DGP
@mildsunrise
mildsunrise / README.md
Last active February 7, 2024 15:11
🖥 Lightweight diskless VM with QEMU (Arch Linux variant)

🖥 Lightweight diskless VM with QEMU (Arch Linux variant)

This document describes a process to quickly setup a Linux VM for testing or kernel development.

The VM requires no disk image, instead it boots off a directory on the host (using virtiofs). This is:

  • more performant (no FS-in-FS overhead)
  • more convenient for experiments (both host and guest can modify files concurrently)
  • safer (no corruption* in case of kernel panic)
  • easier to set up
@mildsunrise
mildsunrise / mp4parser.py
Last active April 23, 2024 12:47
🕵️‍♀️ MP4 parser / dissector for the command line
#!/usr/bin/env python3
'''
Portable* ISO Base Media File Format dissector / parser.
Usage: ./mp4parser.py <file name>
(*) Needs Python 3.8+
Goals / development guidelines:
- Low level. Meant as a dissector, i.e. to obtain info about the structure of the file
@mildsunrise
mildsunrise / README.md
Last active May 27, 2023 02:18
🖥 Lightweight diskless VM with QEMU

🖥 Lightweight diskless VM with QEMU

This document describes a process to quickly setup a Linux VM for testing or kernel development.

The VM requires no disk image, instead it boots off a directory on the host (using virtiofs). This is:

  • more performant (no FS-in-FS overhead)
  • more convenient for experiments (both host and guest can modify files concurrently)
  • safer (no corruption* in case of kernel panic)
  • easier to set up
@mildsunrise
mildsunrise / fnmt_handle.py
Last active September 19, 2023 09:11
🔐 Open source implementation of FNMT's certificate configurator v1.0.1 (https://twitter.com/mild_sunrise/status/1585611873860440067)
#!/usr/bin/env python3
'''
Open source implementation of FNMT's certificate configurator v1.0.1
<https://www.sede.fnmt.gob.es/descargas/descarga-software/instalacion-software-generacion-de-claves>
No warranty provided; use this ONLY if you know what you're doing.
Usage: ./fnmt_handle.py <fnmtcr URL>
Fulfills the request indicated by the URL, sending request to answer operation as completed if there are no errors.
For the fnmtcr://request phase, the generated private key is written to "privkey.pem" in current directory.
@mildsunrise
mildsunrise / crc.md
Created May 3, 2022 17:43
Notes about the CRC

Notes about the CRC

Note: this uses the functions of my polynomial_arithmetic library.

mathematical definition

CRC in its core is (I * x^N) mod P, where

  • I are the input bytes converted to a polynomial (bytes 12 53 become 0x1253 aka x^12 + x^9 + x^6 + x^4 + x + 1).
  • P is a polynomial that is a characteristic of the algorithm
  • N is the degree of P (and thus, the number of bits resulting from the CRC operation)
@mildsunrise
mildsunrise / thread_name.cpp
Last active May 2, 2022 15:42
Portable way to set current thread's name (C++11 or later)
// Definition of a SetThreadName function with an emphasis in "portability",
// meaning we prefer cautiously failing over creating build errors (or crashes)
// on exotic platforms. To do this, we only include/link against very
// few & widely available symbols.
#include "thread_name.h"
#if defined(__linux__)
// For Linux use the prctl API directly. prctl symbol
// should be available under any libc.
@mildsunrise
mildsunrise / dump.py
Created January 21, 2022 02:52
dumper / visualizer of GNOME Shell's cogl global atlas (context: https://twitter.com/mild_sunrise/status/1483390533645049856)
# this tool does the following:
# - dump the atlas of a gnome-shell process (its backing texture, as well as the allocations in it).
# - cross-reference the info with the state of the glyph cache and the texture cache (to determine the source of some of the allocations).
# - perform a number of consistency checks on all of that, in the form of assertions,
# - finally, plot the data in a nice figure.
#
# allocations are tinted with a color depending on their status / source:
# - grayish → free space1
# - yellow → glyph cache
# - red → texture cache, but unused
@mildsunrise
mildsunrise / bitmap-tester.html
Last active January 10, 2022 21:20
🔬 Portable HTML file to test a bitmap with different strides (widths) and modes
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bitmap tester</title>
<style>
body {
margin: 20px;
font: 16px Roboto, sans-serif;
}