Skip to content

Instantly share code, notes, and snippets.

View MrHedmad's full-sized avatar
:electron:
Doing a thing...

Luca "Hedmad" Visentin MrHedmad

:electron:
Doing a thing...
View GitHub Profile
@MrHedmad
MrHedmad / iris.csv
Created June 24, 2024 09:08
The IRIS data from R (originally from Fisher's paper).
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
4.6 3.4 1.4 0.3 setosa
5 3.4 1.5 0.2 setosa
4.4 2.9 1.4 0.2 setosa
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MrHedmad
MrHedmad / gen_reads.py
Created January 15, 2024 15:32
Small script to quickly generate synthetic reads from a genome
from tqdm import tqdm
from random import randint, random, choice
from pathlib import Path
from sys import stdout
def rand_bool(chance: float) -> bool:
return random() < chance
@MrHedmad
MrHedmad / metasample.py
Created December 19, 2023 10:41
Metasample - stratified sampling for `.csv` files given some metadata
"""Metasample
This script performs stratified sampling on an input .csv file, reducing the
number of columns and rows.
To run, you must install `pandas` and have `xsv` (https://github.com/BurntSushi/xsv)
in your PATH.
"""
## --- LICENSE ---
@MrHedmad
MrHedmad / README.md
Last active June 26, 2023 08:22
A tiny guide on how to configure a VPN connection to the UniTO VPN from Linux

Connecting Linux to the Unito VPN

The official guide is obviously terrible at doing its job for linux, so I thought I'd write a tiny guide on how to do this myself. I use Arch, so this will be arch-centric. If you use other distros, lookup your version of the same packages as the ones Arch ships, but they should be fairly generic.

Using OpenConnect

Install openconnect. For arch, this is pacman -Syu openconnect. Once you did, you can connect to the VPN through:

@MrHedmad
MrHedmad / layout.md
Created June 2, 2023 08:31
Corne Layout

My Corne Layout

It is based on some online layout that I cannot find. If someone recognizes it, let me know.

The corne has this shape:

┌──┬──┬──┬──┬──┬──┐       ┌──┬──┬──┬──┬──┬──┐
├──┼──┼──┼──┼──┼──┤       ├──┼──┼──┼──┼──┼──┤
├──┼──┼──┼──┼──┼──┤-------├──┼──┼──┼──┼──┼──┤
└──┴──┴──┴──┼──┼──┼──┐ ┌──┼──┼──┼──┴──┴──┴──┘
 └──┴──┴──┘ └──┴──┴──┘
@MrHedmad
MrHedmad / example.py
Created December 16, 2022 15:16
Function to give to argparse as type to test (a bit) for path type
def path_type(
obj_type: Literal["dir", "file", "file_strict"]
) -> Callable[[str], Path]:
assert obj_type in (
"dir",
"file",
"file_strict",
), f"Invalid object type check: {obj_type}"
if obj_type == "dir":
@MrHedmad
MrHedmad / unito-wifi.8021x
Created March 14, 2022 09:57
IWD configuration for Unito-Wifi (Drop it in `/var/lib/iwd/`)
[Security]
EAP-Method=PEAP
EAP-Identity=anonymous
EAP-PEAP-Phase2-Method=MSCHAPV2
EAP-PEAP-Phase2-Identity=myshortusername@unito.it
EAP-PEAP-Phase2-Password=mypassword
[Settings]
AutoConnect=True
@MrHedmad
MrHedmad / latexify_csv.py
Last active October 26, 2020 14:34
Latexify CSV table in Python
"""Generated latex code from a CSV file. Can also escape special characters
that latex cannot support in a string by themselves, such as _."""
from pathlib import Path
def main(csv_path, chars_to_escape=["_"]):
csv_path = Path(csv_path)
latex = "\\begin{table}\n\t\\centering\n\t\\begin{tabular}{|"
with csv_path.open() as csv:
header = next(csv).split(",")