Skip to content

Instantly share code, notes, and snippets.

View webgtx's full-sized avatar
:accessibility:
Hope is not a strategy

Alex Zolotarov webgtx

:accessibility:
Hope is not a strategy
View GitHub Profile
@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
@webgtx
webgtx / kubernetes.repo
Created September 24, 2023 02:09
rpm kubernetes repository
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
@webgtx
webgtx / cs101.md
Created September 16, 2023 22:29
Computer Science 101

Everything you need to know is...

  1. Turing Machine
  2. CPU
  3. Transistors
  4. Bit
  5. Byte
  6. Ascii Character Encoding
  7. Binary
  8. Hexadecimal
@webgtx
webgtx / end.c
Created September 8, 2023 04:14
Error and Die - Simple function to exit the program with error code
#include <stdarg.h>
// END - Error and Die
void end(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vfprintf(stdout, fmt, ap);
fprintf(stdout, "\n");
fflsuh(stdout);
va_end(ap);

TCP socket Error Codes

Code Description
0 Success
1 Operation not permitted
2 No such file or directory
3 No such process
4 Interrupted system call
5 Input/output error
@webgtx
webgtx / insecurypodmanregistry.md
Created August 10, 2023 17:51
How to access podman registry using http only

The next component to look at is the system-wide registries configuration file. On my system, that file resides at /etc/containers/registries.conf. And I will show a somewhat redacted version of mine as an example:

# This is a system-wide configuration file used to
# keep track of registries for various container backends.
# It adheres to TOML format and does not support recursive
# lists of registries.

[registries.search]
registries = ['docker.io', 'registry.fedoraproject.org', 'registry.access.redhat.com']