Skip to content

Instantly share code, notes, and snippets.

View bigspawn's full-sized avatar
🎧
code and phc

Igor Grishin bigspawn

🎧
code and phc
View GitHub Profile
@r3code
r3code / protobuf-guidelines.md
Created April 2, 2021 12:17
Protobuf Guidelines

Используем protobuff версии 3 https://developers.google.com/protocol-buffers/docs/proto3

Придерживаемся стиля https://developers.google.com/protocol-buffers/docs/style

Если вы удалили поля message определенные ранее, то для сохранения совместимости, их номера должны быть помечены как reserved, чтобы их нельзя было использовать повторно после.

Поддержка версионирования API - см. https://google.aip.dev/215

Переиспользуем готовые определения часто используемых типов (время, деньги, дата и др.) см. https://google.aip.dev/213

@gkeep
gkeep / iceberg_light.conf
Last active November 11, 2022 09:17
Iceberg light theme for kitty terminal
background #e8e9ec
foreground #33374c
selection_background #d2d4dd
selection_foreground #33374c
cursor #33374c
cursor_text_color #e8e9ec
# white
@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active September 10, 2024 09:43
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@vasanthk
vasanthk / System Design.md
Last active September 23, 2024 06:28
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@ungoldman
ungoldman / curl_post_json.md
Last active September 17, 2024 16:00
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@scaryguy
scaryguy / change_primary_key.md
Last active August 21, 2024 10:43
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@jboner
jboner / latency.txt
Last active September 24, 2024 06:30
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@douglas
douglas / update_git_repos.sh
Created October 14, 2011 15:04
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do