TIL

tags: learning til

content

parsing yaml might cause security vulnerabilities

  • yaml allows code execution in parsing
  • yaml can have deep nested attributes, causing parser to consume compute resources and leading to DoS

in less, type / to search, then press -i to toggle case sensitivity

  • e.g., /path finds all path, pressing -i finds path/Path/PATH/....

iptables is just a program to configure firewall rules, it’s not a different thing from firewall

  • it’s deprecated but still widely used, nftables is the successor.

firewalld is written in python

TTY options makes the process think it’s running in a terminal, which enables proper terminal behavior

  • coloring, formatting, cursor positioning, ctrl-z/c (signal handling)
  • docker exec -i opens interactive stdin
  • docker exec -it gives stdin and above mention stdout benefits

a process can be disowned

  • run sleep 1000 followed by disown, now sleep will persist after shell is closed
  • disown removes child process from shell’s child process table, so when shell exits, said child process will not receive SIGHUP

Dict key in Python can’t be mutable object because of hash

python’s self is just a convention, any word works

class MyClass:
def __init__(me, name):
    me.name = name
 
def get_name(hi):
    return hi.name
 
c = MyClass("hi")
print(c.get_name())

Go’s go keyword is analogous to & at the end of shell commands

  • go MyFunc() in Go ~= MyFunc() & in shell scripts

SIGHUP

  • signal, hang up
  • it’s usually used a signal to process to reset, reload config
    • can be caught, or ignore by the program
  • SIGTERM graceful shutdown
  • SIGKILL force stop

localhost, 127.0.0.1, and 0.0.0.0

  • localhost maps to 127.0.0.1 and ::1 (IPv6)

    • the three are the same thing
  • 127.0.0.1 is the loopback address

    • it means “only this machine”
    • if something is on 127.0.0.1:5173, it’s only accessible from this machine
  • 0.0.0.0 is the wildcard address

    • it means all IP addresses
  • more practical examples

    • a remote machine has a web app on 127.0.0.1:8080, it can’t only be accessed from the machine
    • a remote machine has a web app on 0.0.0.0:8080, and the machine has a tailscale IP of 100.84.151.31, the web app can be accessed from 100.84.151.31:8080
  • when i run bun run dev --host 0.0.0.0, i see:

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://10.65.117.113:5173/
  ➜  Network: http://100.84.151.31:5173/
  ➜  Network: http://192.168.64.1:5173/
  ➜  press h + enter to show help
  • which means, the machine has 3 different network interfaces, and they can all access the web app