Skip to content

Instantly share code, notes, and snippets.

/*
* ReWild - Replacement for Wildfire.
* Copyright (c) 2016, 2018, 2020 HarJIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
@harjitmoe
harjitmoe / nbtpickle.py
Last active November 1, 2019 16:04
Use the pickle/json/marshal basic API with NBT data.
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
""" Use the pickle/json/marshal basic API with NBT data. """
# Authored by HarJIT in 2019. This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at
# https://mozilla.org/MPL/2.0/.
from ctypes import c_byte, c_int16, c_int32, c_int64, c_float, c_double
@harjitmoe
harjitmoe / system_b_cyrillic.txt
Last active May 29, 2018 12:03
IBUS table for Cyrillic using adapted GOST 7.79 System B mappings.
SCIM_Generic_Table_Phrase_Library_TEXT
VERSION_1_0
BEGIN_DEFINITION
NAME = System B
AUTHOR = HarJIT <harjit@harjit.moe>
LANGUAGES = ru
SERIAL_NUMBER = 20180528
UUID = db34eefb-cc62-46a8-85c2-d5b5a26444df
@harjitmoe
harjitmoe / deseret.txt
Last active April 18, 2018 23:07
IBUS table for Deseret
SCIM_Generic_Table_Phrase_Library_TEXT
VERSION_1_0
BEGIN_DEFINITION
# Library of Congress romanisation of Deseret (followed except for ï, which it does not define):
# > https://www.loc.gov/catdir/cpso/romanization/deseret.pdf
#
# Macron accents (overlines) are represented here by a single x prefix, other accents (umlaut and
# circumflex) are represented by a doubled x prefix.
(obsolete, see https://gist.github.com/harjitmoe/19f0412ec9bb8a6330bce6683fbbb760 )
@harjitmoe
harjitmoe / xhtml2shim.js
Last active July 5, 2017 11:02
JavaScript shim to add support for suitably-namespaced XHTML2 elements in XHTML5 code (currently just <xhtml2:img>). Requires jQuery.
// Namespaces assumed:
// xmlns="http://www.w3.org/1999/xhtml"
// xmlns:xhtml2="http://www.w3.org/2002/06/xhtml2/"
// xmlns:ev="http://www.w3.org/2001/xml-events"
// By Thomas Hori, copyright 2017. Zlib licence.
jQuery(function () { // Good practice to not assume $ at top level is jQuery (due to e.g. PrototypeJS).
var $ = jQuery;
////////////////
# Copyright (c) Secret Labs AB 1997-2003.
# Copyright (c) Fredrik Lundh 1995-2003.
#
# By obtaining, using, and/or copying this software and/or its
# associated documentation, you agree that you have read, understood,
# and will comply with the following terms and conditions:
#
# Permission to use, copy, modify, and distribute this software and its
# associated documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appears in all
@harjitmoe
harjitmoe / pil4pyg2.py
Last active January 19, 2017 17:44
Glue code for using PIL to load images into Pygame
from PIL import Image as pil_image
from pygame import image as pygame_image
def pil2pygame(im):
return pygame_image.frombuffer(im.convert("RGBA").tostring(),im.size,"RGBA")
def open_(name):
try:
im=pil_image.open(name)
except IOError,e: #Compatibility with Pygame
from pygame import base
@harjitmoe
harjitmoe / daemonctl
Last active January 6, 2017 21:52
Send a service stop, start, restart or status instruction to Upstart (via initctl) or systemd (via systemctl) as appropriate. Relevant on e.g. Ubuntu Xenial, which uses systemd for its init, but still retains Upstart for certain Unity-related purposes.
#!/usr/bin/env python
import subprocess, os, sys
DEVNULL = open(os.devnull,"r+")
ctlexes = ["initctl","systemctl"]
provides = ["start","stop","restart","status"]
@harjitmoe
harjitmoe / hangoproc.py
Last active November 12, 2016 21:07
Generate HTML output from Google hangouts takeout data
# (c) Thomas Hori 2016.
# Generate HTML output from Google hangouts takeout data (the _g one is group chats only)
# May be redistributed under terms of Zlib license ("The zlib/libpng License" as defined by
# the Open Source Initiative), which should be affixed.
# Clarifying all mentions of my name or copyright notice with a "modified (by)" line not
# using my name shall be sufficient for plainly marking this particular script as altered.
import marshal, json, time
print ("Loading JSON")