Skip to content

Instantly share code, notes, and snippets.

@Shimmermare
Shimmermare / FastComponentBenchmark.cs
Last active May 2, 2024 03:01
Evaluation of data structures component set of pre-defined types
using System;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Filters;
namespace NetPlayground;
[MemoryDiagnoser]
@Shimmermare
Shimmermare / AgentCapabilitiesGoapSetFactory.cs
Created October 13, 2023 17:04
Goap setup for reference
using System;
using System.Collections.Generic;
using System.Reflection;
using CrashKonijn.Goap.Behaviours;
using CrashKonijn.Goap.Classes.Builders;
using CrashKonijn.Goap.Interfaces;
using UnityEngine;
namespace Megaspell.AI.Capabilities
{
@Shimmermare
Shimmermare / filter_by_rating.py
Last active November 26, 2022 14:55
random fimfarchive tools
import json
import os
from pathlib import Path
# Remove story files with ratings that's not whitelisted
whitelisted_ratings = set(['everyone', 'teen'])
with open('index.json', 'r', encoding='utf-8') as f:
index = json.loads(f.read())
@Shimmermare
Shimmermare / batch_convert_epub_to_txt.py
Created November 25, 2022 16:15
Convert (and replace) all epub files in directory (recursive) with txt
import os
import sys
import glob
from more_itertools import chunked
from multiprocessing import Pool
from epub2txt import epub2txt
from pathlib import Path
# Pre:
# pip install more-itertools
@Shimmermare
Shimmermare / BestiSaveEdit.cs
Last active January 7, 2022 05:13
Util to edit Besti friend save files
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
/// <summary>
/// Use to edit Besti friend save file.
/// Tested on version 9.100
///
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.roundToInt
import kotlin.math.sqrt
const val PRECISION: Double = 0.1
fun main() {
val case0 = Conditions(
sizeX = 3, sizeY = 2, sizeZ = 2,
@Shimmermare
Shimmermare / MotherOfGod.kt
Created May 7, 2020 11:08
Kotlin is flexible. A lot.
import java.lang.IllegalArgumentException as ИсключениеНезаконногоАргумента
import java.lang.StringBuilder as СборщикСтроки
import kotlin.Int as ЦелоеЧисло
import kotlin.String as Строка
/**
* Никогда так не делайте.
*/
fun main() {
val результат = `Создать строку из Н повторений строки С, но не больше М символов`(с = "Боже", н = 100, м = 398)
package com.shimmermare.playgroundjava.misc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
// Union-find problem
public class NumberofIslands2 {
public static void main(String[] args) {
package com.shimmermare.playgroundjava.misc;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BombEnemy {
public static void main(String[] args) {
testCase(10000, 10000, 0.05F, 0.1F, 0);
}
@Shimmermare
Shimmermare / regex.txt
Last active November 29, 2019 19:09
Regex for matching HTML tag
!!! DON'T USE REGEX TO PARSE HTML UNLESS YOU ABSOLUTELY HAVE TO !!!
Match full tag: <\s*(\w+)(?:\s*\w+=(?:"[^"]*"|'[^']*'))*?\s*>(.*?)<\s*\/\s*\1\s*>
Group 1: tag name
Group 2: tag content
! Uses repeated captures, thus isn't supported by Python's re - use this https://pypi.org/project/regex/ !
Match self-closing tag: <\s*(\w+)(?:\s*\w+=(?:"[^"]*"|:'[^']*'))*?\s*\/\s*>
Group 1: tag name