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 / data-find-and-replace.py
Last active August 29, 2015 14:19
find some text words in files and replace it to other words
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import sys
import os, os.path
import csv
import itertools
import random
@polymorphm
polymorphm / wsgi.py
Last active August 29, 2015 14:19
WSGI router (by host) example
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import my_example_1_wsgi as _my_example_1_wsgi
import my_example_2_wsgi as _my_example_2_wsgi
import my_example_3_wsgi as _my_example_3_wsgi
_application_by_host_dict = {
@polymorphm
polymorphm / ipv6down.sh
Last active September 5, 2023 02:22
some config files for IPv6 (DHCPv6-PD over PPPoE)
#!/usr/bin/bash
#
# it is file -- /etc/ppp/ipv6-down.d/99-custom-internet.sh
#
if [ -z "$IFNAME" ] || [ "$LINKNAME" != "domru" ]
then
true
exit