Skip to content

Instantly share code, notes, and snippets.

View docwhat's full-sized avatar

Christian Höltje docwhat

View GitHub Profile
@docwhat
docwhat / Jenkinsfile
Last active December 16, 2023 13:53
Example pipeline usage of the Jenkins Mask Passwords plugin
// Requires https://plugins.jenkins.io/mask-passwords to run
/**
* Runs code with secret environment variables and hides the values.
*
* @param varAndPasswordList - A list of Maps with a 'var' and 'password' key. Example: `[[var: 'TOKEN', password: 'sekret']]`
* @param Closure - The code to run in
* @return {void}
*/
def withSecretEnv(List<Map> varAndPasswordList, Closure closure) {
@docwhat
docwhat / README.md
Last active October 24, 2023 17:08
Build a docker image with bash

Dockerfile as a bash script

A simple experiment.

By creating bash functions for common Dockerfile commands (e.g., RUN, COPY) you can sort of implement docker build as a bash script.

It's sort of like a cheap buildah knockoff.

It creates the image example:build.bash

@docwhat
docwhat / hex-colors-from-strings
Created March 27, 2023 15:08
Just a simple algorithm for figuring out colors based on a string hash
#!/bin/bash
#
# Usage: ./run.bash $(sort --random-sort /usr/share/dict/words| head -n10 ) | tee /tmp/foo.html
set -euo pipefail
function string_to_color_hex {
local -r string="$1"
local -r hash=$(echo -n "$string" | md5sum | cut -d' ' -f1)
local -ir r=$((16#${hash:0:2}))
@docwhat
docwhat / rails31init.md
Created September 3, 2011 03:01 — forked from niquola/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@docwhat
docwhat / profiling.groovy
Last active September 23, 2022 15:46
In Groovy profiling
#!/usr/bin/env groovy
// This works in Jenkinsfiles without approving any scripts.
class MyProfiler {
def timings
def dsl
MyProfiler(dsl) {
this.timings = [:]
module gist.github.com/e3b13265d24471651e02f7d7a42e7d2c
go 1.18
@docwhat
docwhat / symlink-checker-tests.bash
Created June 27, 2022 18:12
Ways of checking if a file is "a symlink" and is "broken".
@docwhat
docwhat / update.bash
Created June 10, 2022 18:49
Script to update MiniUI for the Miyoo Mini
#!/bin/zsh
set -eu
cd "${0:h}"
die() {
echo "death: $*" >&2
exit
}
@docwhat
docwhat / traceback_example.bash
Last active April 6, 2022 02:52
A template showing how to do bash tracebacks. This makes using `set -eu` much more comfortable.
#!/bin/bash
#
# Tracebacks in bash
# https://docwhat.org/tracebacks-in-bash/
#
# Just take the code between the "cut here" lines
# and put it in your own program.
#
# Written by Christian Höltje
# Donated to the public domain in 2013
@docwhat
docwhat / example1
Created December 7, 2015 15:53
choco install dotnet3.5 fails (but succeeds?)
PS C:\Users\Administrator> choco install dotnet3.5 -debug -yes
Chocolatey is running on Windows v 6.3.9600.0
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
Command line: "C:\ProgramData\chocolatey\choco.exe" install dotnet3.5 -debug -yes
Received arguments: install dotnet3.5 -debug -yes
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
output to a gist for review.