Skip to content

Instantly share code, notes, and snippets.

View koenbollen's full-sized avatar

Koen Bollen koenbollen

View GitHub Profile
@koenbollen
koenbollen / punch.py
Created July 5, 2010 19:10
Proof of Concept: UDP Hole Punching
#!/usr/bin/env python
#
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
#
# This is the client.
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
@koenbollen
koenbollen / mastersteam.py
Created October 25, 2010 22:44
Query the Steam master servers.
#!/usr/bin/env python
#
# Query the Steam master servers.
#
# See: http://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
@koenbollen
koenbollen / imgur.py
Created May 20, 2010 22:10
Commandline tool for uploading images to imgur.com.
#!/usr/bin/env python
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
import sys
import os
import optparse
import base64
import urllib2
@koenbollen
koenbollen / spc.py
Created July 4, 2010 21:39
Simple Persistence Caching: make a function cached to disk with a simple decorator.
#!/usr/bin/env python
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
# Simple Persistence Caching
#
import os
import shelve
import urllib2
@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 / 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 / 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 / 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 / Screen.cs
Created April 18, 2011 14:43
A simple but complete ScreenManager for XNA.
using Microsoft.Xna.Framework;
using System.Linq;
namespace Screens
{
/// <summary>
/// This is a screen that can be added to the ScreenManager. Extend it and add components
/// to it in the Initialize() method. You can also override the Update() and Draw() method.
/// </summary>
@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"