Skip to content

Instantly share code, notes, and snippets.

View spdskatr's full-sized avatar

spdskatr

  • University of Cambridge
View GitHub Profile
@spdskatr
spdskatr / rmq_node_update.hpp
Created January 27, 2019 12:13
[PROOF OF CONCEPT] node_update class for __gnu_pbds::tree that allows for O(log n) RMQ capabilities
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
struct met {
int lo, hi, max_v;
};
@spdskatr
spdskatr / hahalolcipher.py
Last active January 8, 2019 13:31
The HAHALOL cipher, designed by yours truly on Jan 2019
# Converts ascii representation of text to a corresponding number in binary
# Each pair of letters is multiplied together to form a bigger number
# 0 is "HA", 1 is "LOL"
import math
alphabet = "abcdefghijklmnopqrstuvwxyz"
# These are the last 127 prime numbers less than 10^5
@spdskatr
spdskatr / qr_decomp.py
Created September 16, 2018 12:45
Solves the matrix equation Ax = b for x using QR decomposition and Gram-Schmidt orthogonalisation.
"""
Solves the matrix equation Ax = b for x using QR decomposition and
Gram-Schmidt orthogonalisation.
Author: spdskatr
"""
import random
import numpy as np
inner_product = np.dot
@spdskatr
spdskatr / rename_target_version.py
Created August 7, 2018 02:09
Renames <targetVersion> tag in any mod's about.xml from 1.0 to current version. Place this file in the same folder as rw's executable to run.
"""
@author: Spdskatr
Renames <targetVersion> tag in any mod's about.xml from 1.0 to current version.
Place this file in the same folder as rw's executable to run.
To change Steam Workshop mods as well, change modsPath to "../../workshop/content/294100"
"""
from __future__ import print_function
import re
@spdskatr
spdskatr / rename_graphic_multi.py
Last active July 20, 2018 07:20
Renames all texture files requiring graphic_multi to the correct extension. Place this file in your mod folder for it to work.
# -*- coding: utf-8 -*-
"""
Renames all texture files requiring graphic_multi to the correct extension.
_back -> _north
_front -> _south
_side -> _east
Place this file in your mod folder for it to work.
@author: Spdskatr
@spdskatr
spdskatr / patchoperation.md
Last active January 31, 2018 00:23 — forked from Zhentar/patchoperation.md
Introduction to PatchOperation

There are 11 new "PatchOperation" actions we can perform to modify Defs without copying the whole thing. This in turn improves mod compatability dramatically - it allows two mods to modify different parts of the same Def without conflict. This guide only describes the basics of each operation available to us.

Patches go in xml files in a subfolder named "Patches" in your mod folder (So "MyMod\Patches", just like you might have "MyMod\Defs" or "MyMod\Textures"). Example.

Each PatchOperation has an "xpath" node, which should contain an xpath selector for the xml node(s) that the operation should affect. This is not an xpath tutorial. If you don't know xpath, not my problem. But minimurgle has you covered!

To illustrate the operations, I'll use this simple example def:

  <DesignationCategoryDef>
{
"logCacheSize": 5000,
"quotes": [
"If you think about it, `bb || !bb` always returns true.",
"SirSatanII: *I am not a command. Please try again later.*",
"Jdalt40: I'm expecting an Easter egg of me 9 AM tomorrow sharp",
"How to mod RimWorld: Copy and paste stuff, get angry at stuff, make other people angry at your stuff.",
"If IE is brave enough to ask you to set it as your default browser, don't tell me you dare not ask a girl out.",
"Namsan: I like to drink tears and bloods",
"Sneaks: How dare you, what did that poor Wolfy ever do to you",