Skip to content

Instantly share code, notes, and snippets.

View weibeld's full-sized avatar

Daniel Weibel weibeld

View GitHub Profile
@weibeld
weibeld / 01-hello-world.yml
Last active May 1, 2024 13:53
GitHub Actions example workflow 1 — Hello World!
name: hello-world
on: push
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: my-step
run: echo "Hello World!"
@weibeld
weibeld / telegram-api.pdf
Last active April 27, 2024 03:18
Telegram CLI Commands
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@weibeld
weibeld / set_prompt.sh
Created December 10, 2015 10:54
Bash Prompt With Exit Code of Last Command
# Set a Bash prompt that includes the exit code of the last executed command.
#
# Setup: paste the content of this file to ~/.bashrc, or source this file from
# ~/.bashrc (make sure ~/.bashrc is sourced by ~/.bash_profile or ~/.profile)
#
# Daniel Weibel <danielmweibel@gmail.com> October 2015
#------------------------------------------------------------------------------#
# Command that Bash executes just before displaying a prompt
export PROMPT_COMMAND=set_prompt
@weibeld
weibeld / prometheus.yml
Created July 31, 2019 06:07
Example Prometheus configuration (scrape config)
global:
scrape_interval: 10s
scrape_configs:
- job_name: node
static_configs:
- targets:
- localhost:9100
- job_name: python-app
static_configs:
- targets:
@weibeld
weibeld / 10-use-case-1.yml
Last active April 19, 2023 22:39
GitHub Actions example workflow — Use Case 1
name: release
on:
release:
types: [published]
jobs:
main:
runs-on: ubuntu-latest
env:
ARCHIVE_NAME: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}
steps:
@weibeld
weibeld / setCrop.m
Last active March 22, 2023 16:58
Matlab functions for setting tight margins around a figure, and setting the paper size to the figure size
% setCrop - Adjust paper size to figure size of current figure.
%
% Usage:
% setCrop()
%
% Notes:
% Call this function after all plotting commands, after calling
% "setTightMargins", but before calling "print".
%
% Daniel Weibel <danielmweibel@gmail.com> November 2015
@weibeld
weibeld / kubernetes-books.md
Last active November 8, 2022 21:37
List of Kubernetes books
@weibeld
weibeld / getopt-std.pl
Last active October 30, 2022 08:24
Reference example for using the Getopt::Std Perl module
use strict;
use warnings;
use feature qw(say);
use Getopt::Std;
# If set to true, exit script after processing --help or --version flags
$Getopt::Std::STANDARD_HELP_VERSION = 1;
our $VERSION = "0.1";
#------------------------------------------------------------------------------#
@weibeld
weibeld / medium-article-with-canonical-link.sh
Created July 31, 2019 06:19
Bash script for creating a Medium article with a canonical URL through the Medium API
#!/bin/bash
set -e
TITLE=$1
CANONICAL_URL=$2
if [[ "$#" -ne 2 ]]; then
cat <<EOF
USAGE
@weibeld
weibeld / k8s-check-container-user.sh
Created September 8, 2022 12:28
Check user of all containers in a Kubernetes cluster
#!/bin/bash
kubectl get pods --all-namespaces -o 'custom-columns=:.metadata.namespace,:.metadata.name,:.spec.initContainers[*].name' |
while read line; do
namespace=$(awk '{print $1}' <<<"$line")
pod=$(awk '{print $2}' <<<"$line")
containers=($(awk '{print $3}' <<<"$line" | tr , ' '))
for container in "${containers[@]}"; do
echo -n "$namespace | $pod | $container: "
kubectl exec "$pod" -n "$namespace" -c "$container" -- whoami 2>/dev/null || echo "<unknown>"