Skip to content

Instantly share code, notes, and snippets.

View steevehook's full-sized avatar
📖
redefining education

Steve Hook steevehook

📖
redefining education
View GitHub Profile
SELECT
pg_stat_activity.query,
pg_locks.locktype,
pg_locks.mode,
pg_locks.granted
FROM
pg_locks
JOIN
pg_stat_activity
ON
SELECT
pg_stat_activity.query,
pg_locks.locktype,
pg_locks.mode,
pg_locks.granted
FROM
pg_locks
JOIN
pg_stat_activity
ON
@steevehook
steevehook / latency.txt
Created March 8, 2024 13:29 — forked from jboner/latency.txt
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
package workers
type worker interface {
Start() error
}
func NewWorker(w worker) Worker {
return Worker{
worker: w,
}
@steevehook
steevehook / bot.rb
Created August 11, 2023 18:31 — forked from dideler/bot.rb
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
kubectl patch configmap session-manager-image-config -n dev -p '{"data":{"GS_AGONES_IMAGE":"eu.gcr.io/project-location/gameserver:r14843-r485-Shipping"}}'
kubectl rollout restart deployment/session-manager -n dev
https://comco.zulipchat.com/api/v1/external/gitlab?api_key=<BOT_API_KEY>&stream=<STREAM_NAME>%2Fmerge-requests&branches=main

HTTP API Errors

Proposed Error Structures

Simple Example

{
  "type": "supported_error_type",
  "message": "a message describing the error in general"
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
benchmark(100_000)
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
n := 1_000_000