Skip to content

Instantly share code, notes, and snippets.

@polymorphm
polymorphm / wg-internet.conf
Last active January 30, 2024 20:58
wg-quick to Global Internet usefull ip rules details
[Interface]
PrivateKey = ...
Address = ...
DNS = ...
FwMark = 2901
Table = 2901
PostUp = ip -4 rule add pri 2999 lookup default || true
PostUp = ip -4 rule add pri 2010 to 10.0.0.0/8 goto 2999 || true
PostUp = ip -4 rule add pri 2010 to 172.16.0.0/12 goto 2999 || true
@polymorphm
polymorphm / install-vmlinuz-linux.sh
Last active August 16, 2020 17:56
/etc/install-vmlinuz-linux.sh: coping/generation vmlinuz and initramfs
#!/bin/bash
set -e
boot_vmlinuz_path='/boot/vmlinuz-linux'
boot_initramfs_path='/boot/initramfs-linux.img'
new_boot_vmlinuz_path="$boot_vmlinuz_path.new"
new_boot_initramfs_path="$boot_initramfs_path.new"
bak_boot_vmlinuz_path="$boot_vmlinuz_path.bak"
bak_boot_initramfs_path="$boot_initramfs_path.bak"
@polymorphm
polymorphm / br-lan-init.service
Last active May 20, 2022 09:02
/etc/nftables.conf , /etc/systemd/system/br-lan-init.service , /etc/br-lan-init.sh , /etc/openvpn/client/unloved-public-inet-hook.sh , /etc/wireguard/mullvad-se14.conf , /etc/wireguard/wg-vpn-hook.sh , /etc/systemd/networkd.conf
[Unit]
Description=br-lan init script
After=network.target
Before=network-online.target
[Service]
Type=oneshot
ExecStart=/etc/br-lan-init.sh start
ExecStop=/etc/br-lan-init.sh stop
RemainAfterExit=yes
@polymorphm
polymorphm / kernel-flash
Last active November 22, 2019 19:50
running kernel from a flash; and verifying that boot files are still okay
#!/usr/bin/bash
kernel_flash_name='plm-notebook'
boot_path='/boot'
kernel_vmlinuz_file='vmlinuz-linux'
kernel_img_files=('intel-ucode.img' 'amd-ucode.img' 'initramfs-linux.img')
kernel_cmdline="\\kernels\\$kernel_flash_name\\$kernel_vmlinuz_file.efi initrd=\\kernels\\$kernel_flash_name\\intel-ucode.img initrd=\\kernels\\$kernel_flash_name\\amd-ucode.img initrd=\\kernels\\$kernel_flash_name\\initramfs-linux.img root=UUID=6581314d-6709-416e-9c61-166211b7163e rw rootflags=subvol=arch1-root rd.luks.name=e85a4aea-f191-431c-b6f8-93ba70d95d73=root loglevel=3 quiet"
flash_path='/dev/disk/by-id/usb-SanDisk__Cruzer_Fit_4C530000240815113164-0:0'
flash_part_path="$flash_path-part1"
run_path="/run/$kernel_flash_name.kernel-flash"
// gcc -Wall -Wextra -o hrenov-kompilator hrenov-kompilator.c
// or: gcc -Wall -Wextra -O3 -o hrenov-kompilator hrenov-kompilator.c
// or: clang -Wall -Wextra -o hrenov-kompilator hrenov-kompilator.c
// or: clang -Wall -Wextra -O3 -o hrenov-kompilator hrenov-kompilator.c
#include <stdlib.h>
#include <stdio.h>
int
main (int argc __attribute__ ((unused)),
@polymorphm
polymorphm / bubble-lab.c
Last active November 6, 2018 17:36
simple bubble sorting of vectors (by their length). just for test
// to compile:
// gcc -Wall -Wextra -O3 -funsafe-math-optimizations -o bubble-lab bubble-lab.c
// or
// gcc -Wall -Wextra -O3 -funsafe-math-optimizations -DCANNOT_RANDOM -o bubble-lab bubble-lab.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifndef CANNOT_RANDOM
#!/usr/bin/python
# -*- mode: python; coding: utf-8 -*-
import sys
import os, os.path
import json
def main():
# the path to cloned directory https://github.com/hyperboria/peers
peer_dir_path = sys.argv[1]
@polymorphm
polymorphm / make-amd-ucode.sh
Last active February 24, 2020 20:59
/boot/make-amd-ucode.sh
#!/bin/bash
set -e
cd -- /boot
rm -vf -- amd-ucode.img.new
rm -vRf -- amd-ucode-work
mkdir -v -- amd-ucode-work
cd -- amd-ucode-work
mkdir -v -- kernel kernel/x86 kernel/x86/microcode
@polymorphm
polymorphm / pesni-tut-net-make-xspf.js
Last active February 14, 2016 21:42
script for web-browser -- for bulk copy MP3 files from http://pesni-tut.net/
// -*- mode: js; coding: utf-8 -*-
(function (global) {
'use strict'
var MAIN_NAME = 'pesni-tut-net-make-xspf'
var XSPF_XMLNS = 'http://xspf.org/ns/0/'
function replace_cycle (str, old_sub_str, new_sub_str) {
var new_str
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import sys
import xml.etree.ElementTree as ET
import itertools
CATEGORY_COLUMN_FIELD = 1