Skip to content

Instantly share code, notes, and snippets.

@pertsevds
pertsevds / atom.py
Created July 13, 2021 19:50 — forked from Morgul/atom.py
Atoms/Symbols in Python
class atom(object):
"""An implementation of the atom concept, inspired by Erlang.
Modified from here: http://www.me.net.nz/blog/atoms-slash-symbols-in-python/
"""
def __init__(self, a):
self._a = intern(a)
def __eq__(self, other):
@pertsevds
pertsevds / tunnel.py
Created September 29, 2022 17:57 — forked from carlohamalainen/tunnel.py
check ssh tunnel from Python
"""
From the man page for ssh:
-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask
for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way
to start X11 programs at a remote site is with something like ssh -f host xterm.
If the ExitOnForwardFailure configuration option is set to “yes”, then a client started with -f will wait
for all remote port forwards to be successfully established before placing itself in the background.
@pertsevds
pertsevds / git-use-main.md
Created October 28, 2022 15:03 — forked from clarkphp/git-use-main.md
Use default branch name of "main" instead of "master" in Git repositories

Set default branch name for new repositories to "main"

git version 2.28+

$ git config --global init.defaultBranch main

git version 2.27 or less

@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
@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 / 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 / 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 / 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 / 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 / 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"