Navigation Menu

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 / 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"
#!/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]
@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
@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"
@SupaHam
SupaHam / PoundValue.kt
Last active July 14, 2016 13:27
Using Kotlin to increase pound value.
/*
* @jkbbwr provided the workaround below where you prefix the trailing s with a number such as 1.
* The number preceding the s is a padding, but if it's set to 1, there won't be any padding if your string isn't empty.
* This works because a variable cannot start with a number, so Kotlin immediately escapes $ if a number follows.
*/
fun main(args: Array<String>) {
println("""
|CREATE TABLE IF NOT EXISTS `%1$1s` `%2$1s` `%1$1s` (
| ...
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 / JLog.YAML-tmLanguage.yaml
Last active June 19, 2016 01:18
Bukkit .log highlighing. Designed for Solarized (Dark). Preview: http://supa.me/vbqNuW.png
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: JLog
scopeName: text.jlog
fileTypes: [log]
uuid: 0da65be4-5aac-4b6f-8071-1aadb970b8d3
patterns:
- match: '^\[\d{2}:\d{2}:\d{2}\]\s+\[.*\]:'
name: comment.line.number-sign.perl.text.log
@SupaHam
SupaHam / Preferences.sublime-settings
Created June 15, 2016 01:46
My sublime settings on desktop.
// SupaHam (https://github.com/SupaHam)
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by file type specific settings.
{
"fade_fold_buttons": false,
"translate_tabs_to_spaces": true,
"always_show_minimap_viewport": true,