Skip to content

Instantly share code, notes, and snippets.

Avatar

Alba Mendez mildsunrise

View GitHub Profile
@mildsunrise
mildsunrise / install-ubuntu-by-netboot.md
Last active Feb 7, 2021
Boot an Ubuntu ISO through network (with EFI)
View install-ubuntu-by-netboot.md

Netboot Ubuntu with EFI

This method is not netinst. The ISO is downloaded from a URL into RAM, and mounted. After that, installation proceeds exactly as if it was a pen drive / CDROM, and the network cable can be disconnected if you want.

You do not need internet in either computer, just the ISO file.

We don't touch any system files, just delete $TFTPROOT and dnsmasq.conf when you're done.

Before you begin

@mildsunrise
mildsunrise / enmiendas-pdl-nombre.md
Last active Jan 25, 2021
Summary about spanish bill 122/000072 amendments
View enmiendas-pdl-nombre.md

Enmiendas PdL cambio de nombre (122/000072)

EAJ-PNV

Afectan al artículo 8, que permite bajo ciertas condiciones que los extranjeros que no hayan podido hacer el cambio de nombre en su país lo hagan aquí:

  • #1 [tecnicidad] El artículo 8 pasa a ser una disposición en sí misma (neutra)
  • #2 [tecnicidad] Retoque de redacción en el artículo 8 (algo buena)

Cs

@mildsunrise
mildsunrise / arithmetic.py
Last active Jan 15, 2021
Integer (and polynomial) modular arithmetic for Python!
View arithmetic.py
"""
INTEGER MODULAR ARITHMETIC
These functions implement modular arithmetic-related functions (GF(p)).
As an implied precondition, parameters must be integers unless otherwise noted.
This code is NOT safe to use for cryptography.
"""
def gcd(a, b):
""" Euclidean algorithm (iterative).
@mildsunrise
mildsunrise / linux_to_hid.c
Created Jan 13, 2021
Linux keycode to USB HID translation table (see https://alba.sh/keycodes)
View linux_to_hid.c
// Based on "usb_kbd_keycode" from drivers/hid/usbhid/usbkbd.c @ 1a59d1b
// Maps KEY_BACKSLASH into 0x31 (not 0x32)
static const int linux_to_hid[256] = {
0, 41, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 45, 46, 42, 43,
20, 26, 8, 21, 23, 28, 24, 12, 18, 19, 47, 48, 40,224, 4, 22,
7, 9, 10, 11, 13, 14, 15, 51, 52, 53,225, 49, 29, 27, 6, 25,
5, 17, 16, 54, 55, 56,229, 85,226, 44, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 83, 71, 95, 96, 97, 86, 92, 93, 94, 87, 89,
90, 91, 98, 99, 0,148,100, 68, 69,135,146,147,138,136,139,140,
@mildsunrise
mildsunrise / hid_keycodes.md
Last active Jan 10, 2021
USB HID keycode table + JSON, extracted from HID Usage Tables v1.21
View hid_keycodes.md

Keyboard/Keypad Page (0x07)

This section is the Usage Page for key codes to be used in implementing a USB keyboard. A Boot Keyboard (84-, 101- or 104-key) should at a minimum support all associated usage codes as indicated in the Boot column below.

The usage type of all key codes is Selectors (Sel), except for the modifier keys Keyboard Left Control (0x224) to Keyboard Right GUI (0x231) which are Dynamic Flags (DV).

Note: A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key

@mildsunrise
mildsunrise / README.md
Last active Dec 31, 2020
Render LaTeX inline code to a small image
View README.md

Quick boilerplate for when you need a LaTeX inline thing converted to an image. Enter the expression in fig.tex, and run:

pdflatex fig.tex < /dev/null && convert -density 600 fig.pdf -flatten -scale 50% -quality 90 fig.jpg

Things you may want to change:

  • To render block content (i.e. an equation) instead of a float or inline content, add varwidth=40em to the document options, or use \minipage for a fixed width.
  • Tweak the -density, -quality and border accordingly, or produce a .png.
@mildsunrise
mildsunrise / reverse_crc.py
Last active Dec 12, 2020
calculate the seed, given a message and its expected CRC32
View reverse_crc.py
from zlib import crc32
from polynomial_arithmetic import p_mod_mul, p_mult_inv, p_mod_pow
reverse32 = lambda x: int('{:032b}'.format(x)[::-1], 2)
rev_neg_32 = lambda x: reverse32(x ^ ((1 << 32) - 1))
# generic (mathematical version): get the required seed given the actual and expected CRC, the polynomial and message size
get_seed = lambda msgbits, checksum1, checksum2, poly: \
p_mod_mul(checksum1 ^ checksum2, p_mod_pow(p_mult_inv(2, poly), msgbits, poly), poly)
@mildsunrise
mildsunrise / sona_gif.py
Last active Dec 2, 2020
GIF of chilling Sona
View sona_gif.py
# 1. download video:
# youtube-dl -f 399 https://www.youtube.com/watch?v=hawThTG5No8 -o youtube_video.mkv
# 2. extract important segment:
# ffmpeg -ss 1:08 -to 1:27 -i youtube_video.mkv -c copy -map 0:0 out.mkv
# 3. run this to generate out.gif
from math import tau
import numpy as np
import cv2
import av
@mildsunrise
mildsunrise / der.ts
Last active Nov 7, 2020
low-level DER encoding / decoding
View der.ts
/**
* Low-level DER parser / encoder
*/
/** */
export interface PrimitiveDerNode {
tagClass: TagClass
tagNumber: bigint
value: Buffer
}
@mildsunrise
mildsunrise / README.md
Last active Nov 2, 2020
Helper program to add HTTP/SOCKS proxy support to SSH
View README.md

ssh-proxy-dialer

This program adds proxy support to ssh. Once installed, ssh will obey the ssh_proxy environment variable (or all_proxy as a fallback) and will try to connect to the server through that proxy. Example:

export ssh_proxy="socks5://10.139.2.1:8066"
ssh example.com  # will connect through SOCKS5 proxy