Skip to content

Instantly share code, notes, and snippets.

View pre's full-sized avatar
🚀
Cloud & Kubernetes

Petrus Repo pre

🚀
Cloud & Kubernetes
View GitHub Profile
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
image_size_for_linux_amd64() {
linux_amd64_entry=$(docker manifest inspect -v "$1" | jq -c 'if type == "array" then .[] else . end' | jq -r '. | select(.Descriptor.platform.os=="linux" and .Descriptor.platform.architecture=="amd64")')
echo "$linux_amd64_entry" | jq -c 'if has("SchemaV2Manifest") then .SchemaV2Manifest else .OCIManifest end' | jq -r '[ .layers[].size ] | add '; #| numfmt --to iec --format '%.2f';
}
@Nipsuli
Nipsuli / second_login.sql
Created August 18, 2022 07:19
Example on how to get timestamp for second login. Used to educate about Non-Equi JOIN in SQL
WITH
base AS (
SELECT
SAFE_CAST (
JSON_EXTRACT_SCALAR (payload, '$.timestamp') AS timestamp
) AS event_time,
JSON_EXTRACT_SCALAR (payload, '$.action') AS action_type,
JSON_EXTRACT_SCALAR (payload, '$.actor_id') AS actor_id,
JSON_EXTRACT_SCALAR (payload, '$.actor_username') AS actor_username,
FROM
@mapehe
mapehe / rant.md
Last active December 5, 2021 09:17
don't know why i wrote this

Rant: I'm sick and tired of cryptobros.

I'm gonna go out on a limb here and claim that the general interest in cryptocurrencies is directly proportional to the BTC/USD rate.

Remember the 2018 bubble, when everyone made delusional claims along the lines of the blockchain will replace the internet? It got so big that even a bunch of companies bought the hype. Cash was thrown at business projects that made no goddamn sense: I distinctly remember asking the Finnish MD of a major financial organization how their blockchain proof-of-concept was supposed to work. They

@ulkeshkosh
ulkeshkosh / pci-passthrough.md
Last active February 2, 2024 07:05
PCI-Passthrough Rig, OS, and Setup

Introduction

This is my guide for a successful PCI-Passthrough from Linux (Arch Linux) to QEMU/KVM via virt-manager and libvirtd into a Windows 10 Home guest.

NOTE: This is a guide for Intel only. I do not own an AMD machine, and will not add AMD information this guide until such time that I do, which could be never.

Hardware

Device Type Device
CPU Intel Core i7 7700K Quad-Core, Hyperthreading
Motherboard Gigabyte Z270X-Gaming 5
#!/usr/bin/env bash
#
# see: https://gist.github.com/gregorynicholas/2160046ec6946a2ce0fa
# src: https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# updated: 2015-06-06
#
# ask for the administrator password upfront
sudo -v
@XVilka
XVilka / TrueColour.md
Last active April 27, 2025 10:17
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@emersonf
emersonf / s3etag.sh
Last active April 4, 2025 08:33
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 22, 2025 16:46
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'