Skip to content

Instantly share code, notes, and snippets.

View dangra's full-sized avatar
🦖

Daniel Graña dangra

🦖
View GitHub Profile
@dangra
dangra / remote
Created December 8, 2023 18:24 — forked from tavianator/remote
Remote access mkinitcpio hook
#!/bin/bash
add_user() {
getent passwd "$1" >>"$BUILDROOT/etc/passwd"
getent shadow "$1" >>"$BUILDROOT/etc/shadow"
getent group "$(id -Gn "$1")" >>"$BUILDROOT/etc/group"
}
build() {
add_systemd_unit cryptsetup-pre.target
@dangra
dangra / merge_vs_rebase_vs_squash.md
Created December 7, 2023 21:03 — forked from mitchellh/merge_vs_rebase_vs_squash.md
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion:

@dangra
dangra / prom-k8s-request-limits.md
Created November 9, 2021 01:31 — forked from max-rocket-internet/prom-k8s-request-limits.md
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) /
#!/usr/bin/env perl
use feature 'switch';
use strict;
use warnings;
use Data::Dumper;
use File::Basename;
use File::Copy;
use File::Path qw/make_path/;
@dangra
dangra / perf_queues.py
Created August 10, 2012 12:55 — forked from andrix/perf_queues.py
perf script to test queue performance
import sys
import time
from collections import deque
N = 10000
class FifoMemoryQueue(object):
"""Memory FIFO queue."""
def __init__(self):