Skip to content

Instantly share code, notes, and snippets.

View webgtx's full-sized avatar
😃
soft wrap users, what is it like to watch a tennis match in a fullscreen editor?

Alex Zolotarov webgtx

😃
soft wrap users, what is it like to watch a tennis match in a fullscreen editor?
View GitHub Profile
@webgtx
webgtx / creditcardvalidator.py
Created August 29, 2024 09:15
Luhn Algorithm in Python
from fire import Fire
def checksum(cardnumber: int):
cardnumber = [int(i) for i in str(cardnumber)]
cardnumber.reverse()
odd = [v for i, v in enumerate(cardnumber) if i % 2 == 0]
even = [v for i, v in enumerate(cardnumber) if i % 2 != 0]
even_sum = int()
for i in even:

How to change prefers-color-scheme via gsettings

I recently encountered an issue where my Google Chrome browser was unable to set the prefers-color-scheme option to dark, even though I had configured it to do so in the gtk settings.ini file. This problem only occurred with Sway; in other desktop environments, Chrome set that option correctly.

The solution to this problem was the following command:

gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
@webgtx
webgtx / gist:22f8f02b7d019237c5eccabaee2883d3
Last active August 11, 2024 04:38
System Container Unit
# $HOME/.config/containers/systemd/alpinetop.container
[Unit]
Description=Alpine with a running top
after=local-fs.target
[Container]
Image=docker.io/alpine:3.16
Exec=top
[Install]
import curses
from urllib.request import urlopen
import json
from time import sleep
fetch_todo = lambda: json.loads(urlopen("https://jsonplaceholder.typicode.com/todos").read())
stdscr = curses.initscr()
curses.noecho()
from pathlib import Path
generator = Path().iterdir()
print(generator) # generatorx98e1c
print(sorted(generator)) # [PurePath(".bashrc"), PurePath(".vimrc")]
@webgtx
webgtx / pyyaml.py
Last active June 1, 2024 18:18
How to load yaml configuration files in python
# pip install pyyaml
import yaml
with open("config.yaml", "r") as f:
data = yaml.safe_load(f)
from prompt_toolkit import prompt, HTML
from prompt_toolkit import print_formatted_text as print
from prompt_toolkit.application import run_in_terminal
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.lexers import PygmentsLexer
from prompt_toolkit.styles import Style
from prompt_toolkit.completion import NestedCompleter
from prompt_toolkit.validation import Validator, ValidationError
from os import getcwd
@webgtx
webgtx / termsolution.sh
Created March 6, 2024 22:34
If you can't backspace or tab via ssh
export TERM=vt100
@webgtx
webgtx / static.json
Created December 18, 2023 06:38
AWS S3 Static Website bucket policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
@webgtx
webgtx / pdmnaccsfs.sh
Last active December 3, 2023 13:31
Podman access host filesystem with mount
podman run -it --rm -v /var/data:/sqm --security-opt label=disable docker.io/library/alpine sh
# OR
podman run -it --rm -v /var/data:/sqm:z docker.io/library/alpine sh # secure way