Skip to content

Instantly share code, notes, and snippets.

View koenbollen's full-sized avatar

Koen Bollen koenbollen

View GitHub Profile
@koenbollen
koenbollen / client.go
Last active September 4, 2019 12:06
Quick http client with header override for authentication.
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
)
type TestClient struct {
@koenbollen
koenbollen / hotkey.go
Created July 4, 2018 12:20
Commandline hotkey tool. Usage: `hotkey F12 say hello`
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 / fortnite-status-discord.go
Last active June 11, 2018 11:07
Post changes in Fortnite's server status to Discord.
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
@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 / idle_darwin.go
Created October 3, 2017 14:44
Golang example of detecting user activity (using CGEventSourceSecondsSinceLastEventType from CoreGraphics)
package main
// #cgo LDFLAGS: -framework CoreGraphics
// #include <CoreGraphics/CoreGraphics.h>
import "C"
import (
"fmt"
"math"
)
@koenbollen
koenbollen / kns.bash
Last active August 13, 2020 10:31
kns - Quick kubectl namespace switcher
#!/bin/bash
# kns lets you select a kubernetes namespace in seconds. Autocomplete,
# type-ahead, everything! (tested in bash and zsh)
kns() {
local current
local namespace
local selected
if [[ ! -x "$(which fzf 2>/dev/null)" ]]; then
echo "please install: github.com/junegunn/fzf" >&2
@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 / 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
}