Skip to content

Instantly share code, notes, and snippets.

View Banane9's full-sized avatar

Arne Kiesewetter Banane9

View GitHub Profile
@Banane9
Banane9 / NeosLibraryLoader.cs
Created December 6, 2023 00:12
Dynamically finds the install location of Neos through Steam and dynamically resolves references to its DLLs.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.Win32;
namespace NLL
{
@Banane9
Banane9 / ExpandoDictionary.cs
Created December 6, 2019 01:43
IDictionary that keeps each key added to it instead of overwriting
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ExpandoDictionary
{
public sealed class ExpandoDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{
private readonly Dictionary<TKey, List<TValue>> content = new Dictionary<TKey, List<TValue>>();
@Banane9
Banane9 / TelegramPassportElementsIdea.cs
Created July 27, 2018 10:42
Idea for how to implement the restraints of the Telegram Passport elements
public abstract class PassportElement
{
public abstract string Name { get; }
}
public interface ICompatibility<TWith>
{ }
public sealed class PassportElementErrorDriverLicense : PassportElement, ICompatibility<PassportElementErrorDataField>
@Banane9
Banane9 / MonochromaticAlpha.cs
Created May 19, 2017 20:01
Paint.Net plugin that makes all completely transparent pixels have the same RGB values.
// Name: Monochromatic Alpha
// Submenu:
// Author: Banane9
// Title: Monochromatic Alpha
// Version: 1.0.0
// Desc: Makes all completely transparent pixels have the same RGB values.
// Keywords: adjustment, alpha channel, monochromatic, color, correction, fix
// URL: http://github.com/Banane9
// Help:
@Banane9
Banane9 / SmartEnum.cs
Created April 19, 2017 22:12
How to implement smart "enums" (like in Java) in C#
public abstract class SmartDayOfTheWeek
{
public static SmartDayOfTheWeek Monday { get; } = new Monday();
public static SmartDayOfTheWeek Tuesday { get; } = new Tuesday();
// Etc...
public static IEnumerable<SmartDayOfTheWeek> Days
{
get
{
@Banane9
Banane9 / PointList.cs
Created February 16, 2015 21:28
Notifying Point List for glinkis
using System.Collections;
using System.Collections.Generic;
namespace Railmaker
{
public delegate void ChangedEventHandler(PointList sender, Point item);
public class PointList : IList<Point>
{
private List<Point> points = new List<Point>();
INFO MultiMC 5, (c) 2013-2014 MultiMC Contributors
INFO Version : "0.4.5"
INFO Git commit : "4ae0d8e0af6c0746e6d083829fc4c9a46fa15940"
INFO Work dir before adjustment : "D:/Users/Banane9/Desktop"
INFO Work dir after adjustment : "D:/Users/Banane9/Desktop/MultiMC"
INFO Adjusted by : "Command line D:/Users/Banane9/Desktop/MultiMC"
INFO Binary path : "D:/Users/Banane9/Desktop/MultiMC"
INFO Application root path : "D:/Users/Banane9/Desktop/MultiMC"
INFO Static data path : "D:/Users/Banane9/Desktop/MultiMC"
DEBUG Detected default console font: "Lucida Console" , substitutions: ""
@Banane9
Banane9 / OpenTerra World Spec.md
Last active August 29, 2015 14:08
Spec for the Open Terra World Format

Really old one, where I misunderstood XD ...

(complete maximum length: 68,217,339,393 Bytes - a whopping 63.53 GiB)
ushort tileId
ushort layerDataLength
byte[layerDataLength] layerData (for all Tiles; parsed by Tile)

byte #rows
uint[#rows] bytes offset from start of last one (from start of file for first)
@Banane9
Banane9 / CUDAfy2DMatrix.cs
Created August 3, 2014 18:40
How to use CUDAfy.NET for calculating values from a 2D matrix.
using Cudafy;
using Cudafy.Host;
using Cudafy.Translator;
using System;
using System.Collections.Generic;
using System.Linq;
namespace CudaMath.Int
{
public static class TwoDimensional
local makeSane = function(availableItems) -- output from meController.getAvailableItems()
if type(availableItems) ~= "table" then error("Expected table, got "..type(availableItems)) end
local sanified = {}
for _, stack in pairs(availableItems) do
local rawName = stack.rawName
if stack.beeInfo then rawName = stack.beeInfo.ident end
if sanified[rawName] then
sanified[rawName].qty = sanified[rawName].qty + stack.qty