Skip to content

Instantly share code, notes, and snippets.

View memoryonrepeat's full-sized avatar
🏝️

Thanh Nguyen memoryonrepeat

🏝️
View GitHub Profile
@memoryonrepeat
memoryonrepeat / notes.md
Last active August 20, 2025 17:04
Devops / sysadmin notes

From "Unix and Linux system administration handbook - 5th ed"

  • Process & threads: Use strace for deep debugging
  • For risky commands i.e rm, try with -i (interactive) for confirmation first

From sadservers.com

  • Scenario 1 (figure out which process is writing to some files):
    • fuser <filename> (fuser ~ find user --> return list of processes using the supplied file)
    • Can also use lsof | grep <filename>
  • Scenario 2 (get most frequent visitor's IP from access log): awk '{print $1}' access.log | sort | uniq -c | sort | tail -1
  • Scenario 3 (find which port to knock): Using nmap against all ports nmap -p- localhost
@memoryonrepeat
memoryonrepeat / math.md
Created December 22, 2023 13:30
Useful math intuitions
  • Arithmetic can be seen as a type of transformation
    • Useful when dealing with matrix
  • Can also apply to dot product - measurement of "directional growth" obtained by applying one vector on top of another vector
@memoryonrepeat
memoryonrepeat / k8s-cheatsheet.md
Last active January 25, 2025 22:44
k8s cheatsheet
  • Use kubectx for switching between contexts / namespaces
  • For all commands should specify --namespace <NAMESPACE> or --all-namespaces or kubectl will use default namespace
  • kubectl auth can-i create deployments --namespace <NAMESPACE> --> Check deployment permission
  • General grammar: kubectl <verb> <noun> [options]
  • https://www.digitalocean.com/community/tutorials/how-to-inspect-kubernetes-networking
  • kubectl get pods --namespace=<NAMESPACE> -o wide | grep <SERVICE> --> Get all pods running a service
  • kubectl exec -it <POD> --namespace <NAMESPACE> -- /bin/bash --> Open shell inside some pod. Can also do other commands
  • Port forwarding to access service from localhost (Helm chart message upon successful deployment)
@memoryonrepeat
memoryonrepeat / ideas.md
Created July 4, 2022 07:34
(ir)rational ideas
@memoryonrepeat
memoryonrepeat / metaheuristics.md
Last active July 4, 2022 07:37
Collection of useful metaheuristics observed over time
  • Find a duality. Play duels against each other. What if unstoppable force meet immovable object?
  • Try adding a new dimension and look at the problem from that dimension
  • Think of locality of reference. How to / what does it mean to approach the problem from either spatial / temporal locality ? Is there any other locality (i.e different dimension) that can be used?
  • Reduce to first principles by applying Socratic methods or Five whys
  • Inverse thinking --> analyze backwards
  • Solve a special case / solve a generalized case
  • Max >= average, min <= average (any more general implications?)
  • Second-order thinking -> try to think ahead more than 1 step
  • Think about energy: nature flows in the most optimal way (water from high to low places etc..) --> implications ?
  • Think about entropy: in closed systems entropy always increa
@memoryonrepeat
memoryonrepeat / algo.md
Last active April 25, 2025 15:28
Algo stuff

To practice:

  • Find largest k elements (in terms of value etc...) in a collection. What to do when facing this pattern ?

Sweep line technique

  • Inspired by computational geometry. Ideal for problems involving segments / intervals
@memoryonrepeat
memoryonrepeat / docker-compose.yml
Last active October 14, 2020 11:05
MySQL Docker
version: '3'
services:
fcg-mysql:
image: mysql:5
command: --default-authentication-plugin=mysql_native_password --lower_case_table_names=2
environment:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_ROOT_HOST: "%"
expose:
@memoryonrepeat
memoryonrepeat / cheatsheet.markdown
Last active June 12, 2020 12:24
Selected Sublime shortcuts

https://www.shortcutfoo.com/app/dojos/sublime-text-3-mac/cheatsheet

Navigation

  • CTRL + g: Go to line #
  • CTRL + m: Go to matching bracket

Selection

  • CTRL + SHIFT + m: Select function currently enclosed by current bracket (repeat to select those enclosed by outside brackets)
  • CMD + l: Select current line (repeat to select next line)
  • CMD + d: Select current word (repeat to have more cursors to hightlight same word at other locations, then any change will be applied to all selections - very useful for refactoring) ---> CMD + k + CMD + d: Skip current match
# /cpu/{sub(/requests/, "found!!!!", last)} NR>1{print last} {last=$0} END {print last}
{
# $0 is current line
if ($0 ~ /cpu/ && previous ~ /requests/){
sub(/cpu: "0.1"/,"cpu: \"0.01\"",$0)
print(previous)
}
else if ($0 ~ /cpu/ && previous ~ /limits/) {
sub(/cpu: "0.1"/,"cpu: \"1\"",$0)
@memoryonrepeat
memoryonrepeat / ecosystem.config.js
Last active December 2, 2019 09:50
Start all services using pm2
// https://pm2.io/doc/en/runtime/reference/ecosystem-file/
const appList = [
'auction',
'auth',
'booking',
'car',
'cardata',
'contact',
'document',