Skip to content

Instantly share code, notes, and snippets.

View SupaHam's full-sized avatar

Ali SupaHam

View GitHub Profile
@SupaHam
SupaHam / mongo_registry.go
Created November 6, 2020 23:17
mongo-go-driver UUID decoder & encoder for Golang
// This is a value (de|en)coder for the github.com/google/uuid UUID type. For best experience, register
// mongoRegistry to mongo client instance via options, e.g.
// clientOptions := options.Client().SetRegistry(mongoRegistry)
//
// Only BSON binary subtype 0x04 is supported.
//
// Use as you please
package repository
import (
@SupaHam
SupaHam / minecraft font widths
Last active August 17, 2023 16:20
Minecraft character widths
! length 2
" length 5
# length 6
$ length 6
% length 6
& length 6
' length 3
( length 5
) length 5
* length 5
@SupaHam
SupaHam / DynamicProxies.kt
Last active February 19, 2023 20:16
Dynamic Proxies with Kotlin for accessing private classes.
/*
* Code by @vmironov on Kotlinlang slack.
*
* This code uses dynamic proxies in Java to make it easier to access inaccessible classes via an accessible representation.
*/
inline fun <reified T : Any> createMirror(value: Any) = createMirror(value, T::class.java)
fun <T> createMirror(value: Any, clazz: Class<T>): T {
val loader = clazz.classLoader
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* https://gist.github.com/SupaHam/dad1db6406596c5f8e4b221ff473831c
*
* @author SupaHam (https://github.com/SupaHam)
*/
@SupaHam
SupaHam / .mark2rc.properties
Last active June 11, 2017 12:38
Mark2 convenient commands
task.players=1
task.servers=1
task.users=1
theme=supa
theme.supa.console= dark magenta, default
theme.supa.head= light gray, default
theme.supa.output= light gray, default
theme.supa.mark2= dark red, default
@SupaHam
SupaHam / updateLoans.py
Created May 30, 2017 16:43
Update University of Portsmouth library loans
#!/usr/bin/python
from bs4 import BeautifulSoup
import re, getpass, requests, os, sys
ACCOUNT_URL = "https://capitadiscovery.co.uk/port/account"
SESSION_URL = "https://capitadiscovery.co.uk/port/sessions"
LOANS_URL = "https://capitadiscovery.co.uk/port/account/loans"
FAKE_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0"
@SupaHam
SupaHam / RainbowSky.java
Created December 4, 2014 23:54
Create a colourful sky. The SkyColors are best rendered during day. These colors were the best I could find without repeating them. This triggers a rain effect (on the client side), so it would be wise to cover their heads with blocks, especially far above so they don't hear the rain sounds. I'd recommend Barrier blocks at level 256 in adjacent …
package com.supaham.bukkittesting.protolib;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.supaham.bukkittesting.BukkitTesting;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
#!/usr/bin/python
import csv
import yaml
COMMAND_BOOK_FILE = "plugins/CommandBook/warps.csv"
ESSENTIALS_OUTPUT_DIR = "plugins/Essentials/warps/"
def convertWarp(oldWarp):
name = oldWarp[0]
@echo off
SET sublimePath=C:\Program Files\Sublime Text 3\sublime_text.exe
SET nvimPath=C:\Ali\neovim-qt\nvim-qt.exe
rem add sublime for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%sublimePath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%sublimePath% \"%%1\"" /f
@SupaHam
SupaHam / weepush.py
Last active July 15, 2016 21:41
Weechat script for PushBullet
# Gib me all ur credits kthx
# - ur pal al
import weechat
import re
from pushbullet.pushbullet import PushBullet
SCRIPT_NAME = "weepush"
SCRIPT_AUTHOR = "SupaHam <me@supa.me>"
SCRIPT_VERSION = "1"
SCRIPT_LICENSE = "None"