Skip to content

Instantly share code, notes, and snippets.

@koenbollen
koenbollen / client.go
Last active Sep 4, 2019
Quick http client with header override for authentication.
View client.go
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
)
type TestClient struct {
@koenbollen
koenbollen / hotkey.go
Created Jul 4, 2018
Commandline hotkey tool. Usage: `hotkey F12 say hello`
View hotkey.go
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 Jun 11, 2018
Post changes in Fortnite's server status to Discord.
View fortnite-status-discord.go
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
@koenbollen
koenbollen / k8s_manual_cron
Last active Feb 7, 2018
k8s_manual_cron — Run a configured cronjob now
View k8s_manual_cron
#!/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 Oct 3, 2017
PoC global hotkey for OSX (using RegisterEventHotKey from the Carbon framework)
View hotkey_darwin.go
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 Oct 3, 2017
Golang example of detecting user activity (using CGEventSourceSecondsSinceLastEventType from CoreGraphics)
View idle_darwin.go
package main
// #cgo LDFLAGS: -framework CoreGraphics
// #include <CoreGraphics/CoreGraphics.h>
import "C"
import (
"fmt"
"math"
)
@koenbollen
koenbollen / kns.bash
Last active Aug 13, 2020
kns - Quick kubectl namespace switcher
View kns.bash
#!/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 Mar 28, 2017
Watch Github Pull-Request for their status, exit when green.
View watch-pr.go
package main
import (
"context"
"fmt"
"net/http"
"os"
"regexp"
"sort"
"strconv"
@koenbollen
koenbollen / branch.sh
Created Jan 25, 2016
branch will let you quickly create a git branch prefixed with your username
View branch.sh
# 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
}