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
@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
@jboner
jboner / latency.txt
Last active November 16, 2024 21:28
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
@scaryguy
scaryguy / change_primary_key.md
Last active November 17, 2024 01:16
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;
@ungoldman
ungoldman / curl_post_json.md
Last active October 27, 2024 00:49
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:

@vasanthk
vasanthk / System Design.md
Last active November 17, 2024 05:38
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?
@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active November 11, 2024 08:40
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) /
@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
@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