Skip to content

Instantly share code, notes, and snippets.

View ake-persson's full-sized avatar

Åke Persson ake-persson

  • Utopia Music AG
  • Stockholm
View GitHub Profile
@ake-persson
ake-persson / generate_hostname.sh
Last active August 29, 2015 14:15
Generate dynamic hostname based on hwaddr and aspell dict
#!/bin/bash
out_of_bounds() {
local num=$1 max=$2
while [ $num -gt $max ]; do
num=$(( $num - $max ))
done
echo $num
}
@ake-persson
ake-persson / gist:4046173
Created November 9, 2012 14:59
Puppet MySQL host cleanup trigger and views for facts and resources
use puppet
DROP TRIGGER IF EXISTS trg_hosts_delete;
DELIMITER $$
CREATE TRIGGER trg_hosts_delete AFTER DELETE ON hosts
FOR EACH ROW BEGIN
# Cleanup host related data
DELETE FROM fact_values WHERE host_id = OLD.id;
@ake-persson
ake-persson / docker-gc
Last active March 29, 2016 18:37
Docker garbage collection based on when an image was cached/downloaded
#!/bin/bash
# Root used by Docker runtime
ROOT="/var/lib/docker"
# Device for Docker root
#ROOT_DEV="/dev/vg_root/lv_var"
ROOT_DEV=$(df -T ${ROOT} | awk '/dev/ { print $1 }')
# Docker thinpool device
@ake-persson
ake-persson / boolean-filter.js
Created August 17, 2017 17:13
Angular boolean filter
angular
.module("app.filters", [])
.filter("booleanSearch", booleanSearch)
function booleanSearch() {
return function(rows, search, fields) {
if (typeof search === "undefined") {
return rows;
}
@ake-persson
ake-persson / Dockerfile
Last active March 1, 2018 11:22
Build boot2docker ISO with custom CA certificate for private docker registry
FROM boot2docker/boot2docker
ENV REGISTRY docker-registry
ENV DOMAIN example.com
ENV PORT 8080
# Install CA certificate
RUN mkdir -p $ROOTFS/etc/docker/certs.d/${REGISTRY}:${PORT} ;\
mkdir -p $ROOTFS/etc/docker/certs.d/${REGISTRY}.${DOMAIN}:${PORT}
COPY ca.crt $ROOTFS/etc/docker/certs.d/${REGISTRY}:${PORT}/ca.crt
@ake-persson
ake-persson / get_gh_users.sh
Last active March 6, 2020 15:47
Get Org. GitHub users
#/bin/bash
URL="https://api.github.com"
AUTH="Authorization: token $(cat ~/.ghtoken)"
curl -s -H "${AUTH}" "${URL}/orgs/IndependentIP/members?page=1&per_page=1000" >users.json
echo "login,site_admin,name,email"
for u in $(jq -r '.[] | "\(.login),\(.site_admin),\(.url)"' users.json); do
curl -s -H "$AUTH" "${u##*,}" | jq -r ". | \"${u%,*},\(.name),\(.email)\""
#!/bin/bash
set -eu
error() {
local msg="$1"
echo $msg >&2
exit 1
}
@ake-persson
ake-persson / pull.sh
Last active June 2, 2021 18:19
Pull multiple docker image layers in parallel using curl
#!/bin/bash
set -eu
reg="registry.hub.docker.com"
repo="gliderlabs"
image="alpine"
name="${repo}/${image}"
tag="latest"
parallel=4
@ake-persson
ake-persson / gist:ca29cca70f0b458aee4d
Last active January 28, 2022 17:43
Homebrew Formula for a Go app

Homebrew Formula for a Go app

These are quick notes from making my own Formula and Tap.

Add go build script to your Git repo

gobuild.sh

#!/bin/bash