Skip to content

Instantly share code, notes, and snippets.

import os
from lxml import etree
def find_about_folder(path):
while path != os.path.dirname(path): # stop at root directory
if 'About' in os.listdir(path):
return os.path.join(path, 'About')
path = os.path.dirname(path)
return None
@feldoh
feldoh / LiverProtectionHediffGene.cs
Created October 28, 2023 20:07
Liver Protection Hediff Gene
public class LiverProtectionHediffGene : Gene
{
public static Lazy<HediffDef> LiverProtectionHediff = new(() => DefDatabase<HediffDef>.GetNamed("Your_Cool_Hediff"));
public override void PostRemove()
{
if (GetHediff() is { } firstHediffOfDef)
pawn.health.RemoveHediff(firstHediffOfDef);
base.PostRemove();
@feldoh
feldoh / ContributorCovenant.md
Created April 8, 2023 18:46
Contributor Covenant Code of Conduct

Contributor Covenant Code of Conduct

General Rules:

  1. No 18+ content, this includes violence, nudity, gore, animal abuse, etc
  2. No politics/religion/culture/identity debate, discussion etc.
  3. No attacks, harassment, or sexual misconduct against members or groups.
  4. No warning, mute, or ban dodging.
  5. No encouraging or providing unofficial downloads/piracy for mods, game content, etc.
### Keybase proof
I hereby claim:
* I am feldoh on github.
* I am dexter (https://keybase.io/dexter) on keybase.
* I have a public key whose fingerprint is 78BE 5281 DC44 2A16 8ED1 A208 2554 1F32 A533 3CAA
To claim this, I am signing this object:
@feldoh
feldoh / print_vagrant_inventory.py
Last active August 29, 2015 14:09
A quick python script to generate Ansible inventory lines from the Vagrant ssh-config. Note that you must have run `vagrant up` at least once to ensure that the ports are properly assigned.
import subprocess
import shlex
import sys
import os
# Define function to print a single ansible inventory line from a dictionary of ssh-config values.
def printInventoryLine(host):
print ("{0} ansible_ssh_host={1} ansible_ssh_port={2} " +
"ansible_ssh_private_key_file={3} ansible_ssh_user={4}"
).format(host["Host"], host["HostName"], host["Port"], host["IdentityFile"], host["User"])
@feldoh
feldoh / .bash_profile
Created April 10, 2014 10:03
If you add functions like these to your .bash_profile then by simply typing the name of the function (in this case java7 or java8) into a terminal session, change the version of Java (or anything else) for just that session. This allows you to have whatever version of Java you need as default but freely switch for one time usage of tools like e.…
function java7
{
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
export JAVA_HOME
}
function java8
{
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
export JAVA_HOME
@feldoh
feldoh / TimestampUtils
Created April 10, 2014 09:59
Simple Java function to parse timestamps in many different sources to a valid Java long timestamp in milliseconds.
public static long parseTimestamp(String strTimestamp){
/** Parsing inconsistent timestamps:
* 1 - Sometime they are longs e.g. 230923409234 (Timestamp in milliseconds)
* 2 - Another format is double e.g. 234234234.234 (Timestamp in milliseconds / 1000)
* 3 - Even integers on occasion e.g. 234234234 (Timestamp in seconds)
* 4 - Also e-notation e.g. 1.382298592059E9 (Timestamp in milliseconds / 1000)
* 5 - And e-notation for doubles e.g. 1.380604046071e+12 (Timestamp in milliseconds)
*
* All timestamps in seconds are less than the maximum value of an Integer (2147483647).
* All timestamps in milliseconds are greater than the maximum value of an Integer (2147483647).