Skip to content

Instantly share code, notes, and snippets.

View pertsevds's full-sized avatar

Dmitriy Pertsev pertsevds

  • Russia, Petrozavodsk
  • 13:51 (UTC +03:00)
View GitHub Profile
@pertsevds
pertsevds / 99-usb-serial.rules
Created June 6, 2024 06:43 — forked from cbrake/99-usb-serial.rules
USB Serial udev rules
# /etc/udev/rules.d/99-usb-serial.rules
# udevadm info --attribute-walk -n /dev/ttyUSB0 |grep serial (can be used to get serial number)
# udevadm control --reload-rules (reload rules)
# udevadm trigger (re-add all devices)
# see https://wiki.archlinux.org/index.php/Bus_pirate
# for some reason, ATTRS{bInterfaceNumber}=="00" is not working, hence the use of ENV{}
# single USB/serial adapters
SUBSYSTEM=="tty", ATTRS{serial}=="A900TUKZ", SYMLINK+="ttyUSB_bub_1"
SUBSYSTEM=="tty", ATTRS{serial}=="A700fdWb", SYMLINK+="ttyUSB_bub_2"
brew tap homebrew/cask-fonts
brew install --cask font-cascadia-code
brew install --cask font-cascadia-code-pl
brew install --cask font-cascadia-mono
brew install --cask font-cascadia-mono-pl
@pertsevds
pertsevds / flake.nix
Created October 1, 2023 08:07 — forked from voidus/flake.nix
Build a cloudinit image in nixos
{
description = "A nixos cloudinit base image without nixos-infect";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
@pertsevds
pertsevds / find_fragmentation.erl
Created August 31, 2023 04:52 — forked from dominicletz/find_fragmentation.erl
Erlang script to show used vs. allocated carrier sizes to find impact of memory fragmentation
f().
Str = fun(X) -> io_lib:format("~p", [X]) end.
Percent = fun
(A, 0) -> "100%";
(A, B) -> [Str(round(100*A/B)), "%"]
end.
Get = fun
@pertsevds
pertsevds / wireguard_layer2.md
Created July 20, 2023 08:53 — forked from zOrg1331/wireguard_layer2.md
wireguard, wireguard layer 2, wireguard over TCP

Intro

This note describes how to connect two networks/devices/VMs over public network using Wireguard with Layer 2 support (ARP, IPv6 link-local, etc).

This can also be achieved using SSH and its "tap" tunnel, however, it does not provide the same level of latency and bandwidth as full-blown VPN such as Wireguard.

In addition, this note describes how to tunnel Wireguard over TCP connection. This may be of use if you encounter firewall in-between so, for instance, you can use TCP port 443 only.

Objective

@pertsevds
pertsevds / provision_ubuntu2004_qemu_macosx.sh
Created July 1, 2023 11:05 — forked from relyt0925/provision_ubuntu2004_qemu_macosx.sh
Provisions a Ubuntu 20.04 VM in QEMU on Mac OSX using Cloud-Init
#!/usr/bin/env bash
#Install brew and qemu + cloud init metadata dependencies
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install qemu
brew install cdrtools
rm -rf /tmp/ubuntuqemuboot
#download Ubuntu 20.04 Cloud Image and resize to 30 Gigs
mkdir -p /tmp/ubuntuqemuboot/images
@pertsevds
pertsevds / An Ubuntu WiFi Secure Captive Portal.md
Created June 27, 2023 13:13 — forked from theprojectsomething/An Ubuntu WiFi Secure Captive Portal.md
Guide: An Ubuntu WiFi Secure Captive Portal: Network Manager / DNSMasq / HA Proxy / Let's Encrypt

An Ubuntu WiFi Secure Captive Portal

Improvements, suggestions & fixes are welcome!

Captive portals can be a pain. Here's an opinionated and no-doubt entirely imperfect guide to setting one up for a WiFi access point on Ubuntu (tested on 20+), utilising Network Manager, DNSMasq, HA Proxy and (optionally) Let's Encrypt for a secure, locally hosted landing page.

_Note: This setup was originally designed for an offline WLAN, providing access to a small number of locally hosted domains ... think the WiFi media portal on a flight or boat. If you are looking to provide internet access behind a captive portal then this guide won't get you all the way there. That said, many routers have this capability built in, as do any number of open source router firmware solutions. So you probably don't need to roll your own. If you'd like to try anyway, Ha Proxy Stick Tables would probably come in handy. Very happy to update the guide with any p

@pertsevds
pertsevds / compare_phoenix_versions.exs
Created May 29, 2023 09:49 — forked from aiwaiwa/compare_phoenix_versions.exs
Compare Phoenix Versions with extra custom steps like mix phx.gen.live Accounts User users name:string
#
# Usage:
# elixir <this_script_name.exs> 1.7.2
#
# The script grabs a Phoenix version and places it
# under `phoenix/<version>` subfolder. It attempts to call
# a diff GUI, if there's another version found in `phoenix`.
# It picks the closest older version, if more than one found.
#
# Feel free to modify PhoenixCompareConfig
@pertsevds
pertsevds / upgrade.sh
Last active March 19, 2023 16:33
Upgrade Pnetlab from_any_to_5.3.11 with reboot without confirmation
#!/bin/bash
# Script designed to upgrade PNETLab from almost any version to NEW_PNETLAB_VERSION version
# Requirement: Not having PNETLab 6.x installed for being able to upgrade to NEW_PNETLAB_VERSION
# This script avoids to make this upgrade process twice
# CONSTANTS
NEW_PNETLAB_VERSION=5.3.11
GREEN='\033[32m'
NO_COLOR='\033[0m'
@pertsevds
pertsevds / README.md
Last active March 2, 2023 17:40 — forked from rubencaro/README.md
Python installation guide

Python installation guide

Install asdf and its python plugin, then install Python

asdf lives in https://github.com/asdf-vm/asdf

Follow its installation instructions, which at the moment of writing were:

cd