Skip to content

Instantly share code, notes, and snippets.

View koenbollen's full-sized avatar

Koen Bollen koenbollen

View GitHub Profile
@koenbollen
koenbollen / k8s_manual_cron
Last active February 7, 2018 07:24
k8s_manual_cron — Run a configured cronjob now
#!/bin/bash
# k8s_manual_cron - Run a configured cronjob now
set -euo pipefail
IFS=$'\n\t'
# shellcheck disable=SC2155
main() {
readonly cronjob_name="$1"
local cronjob="$(kubectl get cronjob "$cronjob_name" -o json)"
local jobTemplate="$(printf "%s" "$cronjob" | jq -c .spec.jobTemplate.spec)"
@koenbollen
koenbollen / hotkey_darwin.go
Created October 3, 2017 14:58
PoC global hotkey for OSX (using RegisterEventHotKey from the Carbon framework)
package main
// #cgo LDFLAGS: -framework Carbon
// #include <Carbon/Carbon.h>
// extern void Callback();
// void RunApplicationEventLoop();
// static inline OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData)
// {
// Callback();
// return 1;
@koenbollen
koenbollen / watch-pr.go
Created March 28, 2017 10:31
Watch Github Pull-Request for their status, exit when green.
package main
import (
"context"
"fmt"
"net/http"
"os"
"regexp"
"sort"
"strconv"
@koenbollen
koenbollen / torrentz.user.js
Created October 31, 2010 18:38
A Chrome Userscript that adds direct-download-links to torrent pages of http://torrentz.com/.
// ==UserScript==
// @name Torrentz Direct Link
// @description Adds direct links to torrent pages, you won't have to go to the original index.
// @author Koen Bollen
// @match http://torrentz.com/*
// ==/UserScript==
var rxs = {
'piratebay.org': [
@koenbollen
koenbollen / branch.sh
Created January 25, 2016 12:25
branch will let you quickly create a git branch prefixed with your username
# branch will let you quickly create a git branch prefixed with your username
function branch() {
name=${@:?"mssing argument usage: branch BRANCH NAME"}
slug=$(echo "${name}" | tr -s "A-Z_ " "a-z--" | tr -cd "a-z0-9-" )
cmd="git checkout -b ${USER}/${slug}"
echo -n "\033[37;1m${cmd}?\033[0m [\033[0;32menter\033[0m/\033[0;31mctrl+c\033[0m] "
read || return
eval $cmd
}
@koenbollen
koenbollen / cbs.go
Created October 31, 2015 22:18
ClipBoardServer (in Go, for OSX)
package main
// usage: curl localhost:1544 -d"Text Here"
import (
"io"
"net/http"
"os/exec"
"golang.org/x/text/transform"
@koenbollen
koenbollen / bail.h
Created February 20, 2012 21:20
Old useful C header
/**
* bail.h supplies the macro bail( expr, s ); "no description, read the code"
* version 1.0
* Copyright (C) 2008, Koen Bollen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful,
@koenbollen
koenbollen / wake.py
Created January 20, 2012 22:41
Send a wake-on-lan packet to a certain host specified by name.
#!/usr/bin/env python
# wake.py - Send a wake-on-lan packet to a certain host specified by name.
# The hosts that can be woken are stored a csv file.
#
# Default path for the hosts file is ~/.mac and the
# format is this (one host per line):
# Title, name, mac-address, port
# Example:
# My Computer, living, 00:11:22:33:44:55, 7
#
@koenbollen
koenbollen / load.py
Created September 25, 2011 07:40
Very simple system load monitor.
#!/usr/bin/env python
# load.py
# Test the current load of this system and report through e-mail when it's
# above a given threshold.
#
# Koen Bollen <meneer@koenbollen.nl>
# GPLv2 2011
#
LOAD_THRESHOLD = 0.8 # normalized (load/cpus > LOAD_THRESHOLD)