Skip to content

Instantly share code, notes, and snippets.

View pyproject.toml
[tool.poetry]
name = "test-poetry1"
version = "0.1.0"
description = ""
authors = ["whoizit <whoami@systemli.org>"]
[tool.poetry.dependencies]
python = "^3.8"
django = "^3.0.6"
View sanitizer
#!/usr/bin/env python3
# http://who.int/gpsc/5may/Guide_to_Local_Production.pdf
from sys import argv, exit
if len(argv) == 1:
print(
'''\
{} bottle_volume want_alcohol% have_alcohol% have_peroxide% have_glycerol%
Example: {} 250 60 99.7 3 86\
@whoizit
whoizit / ss+v2ray+cf-wss+ubuntu.sh
Last active Oct 2, 2020
shadowsocks v2ray-plugin cloudflare-wss ubuntu.sh
View ss+v2ray+cf-wss+ubuntu.sh
#!/bin/sh -e
# For Ubuntu 18.04
# How to launch:
# $ curl https://gist.githubusercontent.com/whoizit/5d29de6161270c7eb20c079add6019d2/raw/ss+v2ray+cf-wss+ubuntu.sh
# $ sh ss+v2ray+cf-wss+ubuntu.sh
[ ${EUID:-$(id -u)} -eq 0 ] && {
echo "This script must NOT be run as root"
exit
}
View alpine-setup
### FDE
man mkinitfs-bootparam
# filename and path is important
dd bs=512 count=4 if=/dev/urandom of=/crypto_keyfile.bin
cryptsetup luksAddKey /dev/sda1 /crypto_keyfile.bin
chmod 0 /crypto_keyfile.bin
cat /etc/mkinitfs/mkinitfs.conf
features="... cryptsetup cryptkey"
View weather-fmt
#!/usr/bin/env python3
# pip install -U python-dotenv requests
# https://developer.accuweather.com/accuweather-current-conditions-api/apis/get/currentconditions/v1/%7BlocationKey%7D
import os
import operator
import functools
import requests
import dotenv
View gist:5b37a986204946a95b07fb90343736dc
### Partitioning
fdisk /dev/sda
(o) New DOS table
(n) All free space, Linux filesystem
(w) write and exit
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt
# getkiss.org not available in Russia, so I make short urls for github links
@whoizit
whoizit / tiling-weather.py
Last active Aug 14, 2019
18°(18°) broken clouds, 4m/s, 63%, {}, 756mmHg
View tiling-weather.py
#!/usr/bin/env python3
# pip install --user -U python-dotenv pyowm meteocalc
# get API key in https://openweathermap.org
# create file .env
# OWM_API_KEY=1a1a1a1a1a1a1a1a1
# OWM_PLACE='Saint Petersburg,RU'
# https://github.com/theskumar/python-dotenv
# https://github.com/csparpa/pyowm
# https://github.com/malexer/meteocalc
@whoizit
whoizit / encryptedNixos.md
Last active Dec 7, 2020 — forked from ladinu/encryptedNixos.md
NixOS install with encrypted /boot /root with single password unlock
View encryptedNixos.md

Requirements

  1. Encrypt everthing including /boot and /root
  2. Enter password once

Installation media setup

Download unstable NixOS graphical live iso (cause vim on graphical live iso and easier to read this guide in browser) and write to USB stick.

lsblk
umount /dev/sdX1
dd if=path/to/nixos-graphical-unstable-x86_64-linux.iso of=/dev/sdX bs=10M oflag=direct status=progress
View yggdrasil-ping-public-peers
#!/usr/bin/env python3.7
# requirements:
# python3.7
# pip3.7 install shell-scripting
# fping
#
# instruction:
# git clone https://github.com/yggdrasil-network/public-peers
# cd public-peers
# path/to/yggdrasil-ping-public-peers <region> | sort -rn
@whoizit
whoizit / keycodes
Last active Mar 29, 2019
sway #2999 workaround
View keycodes
# sway workaround
# https://github.com/swaywm/sway/issues/2999
# https://github.com/swaywm/sway/issues/3988
# .config/sway/keycodes
# include ~/.config/sway/keycodes
# switch bindsym to bindcode like that
# from: bindsym $mod+Shift+c reload
# to: bindcode $mod+$C reload