Skip to content

Instantly share code, notes, and snippets.

View 0xF6's full-sized avatar
🧬

Yuuki Wesp 0xF6

🧬
View GitHub Profile
@0xF6
0xF6 / autoclosedoor.cs
Created October 11, 2024 19:24
autoclosedoor.cs
const string VERSION = "42.1.2";
const string DATE = "2021/09/12";
const string INI_SECTION_GENERAL = "Auto Door and Airlock - General Config";
const string INI_GENERAL_ENABLE_AUTO_DOORS = "Enable automatic door closing";
const string INI_GENERAL_ENABLE_AIRLOCK = "Enable airlock system";
const string INI_GENERAL_IGNORE_ALL_HANGAR_DOORS = "Ignore all hangar doors";
const string INI_GENERAL_REGULAR_DOOR_OPEN_TIME = "Default regular door auto close time (s)";
const string INI_GENERAL_HANGAR_DOOR_OPEN_TIME = "Default hangar door auto close time (s)";
const string INI_GENERAL_DOOR_EXCLUDE_NAME = "Auto door exclusion name tag";
const string INI_GENERAL_INTERIOR_DOOR_NAME = "Interior airlock door name tag";
@0xF6
0xF6 / mini_vm.ts
Last active June 20, 2024 16:22
Minimal Virtual Machine realization in typescript
enum Instructions {
NOP, // nope operation
ADD, // addtive operation (sum two stack values)
SUB, // substract
DIV, // divide
MUL, // multiple
LD_ARGS, // load from args into stack (load data value with offset from args into stack)
LDS_NUM, // load constant value into stack
RET // return
}
@0xF6
0xF6 / getCreationDateTelegram.cs
Created September 21, 2023 02:50
Code for getting interpolated creation date by telegram id
using Python.Runtime;
PythonEngine.Initialize();
using var _ = Py.GIL();
var np = Py.Import("numpy");
var polyfit = np.polyfit;
var poly1d = np.poly1d;
internal interface IObserverLinkedList<T>
{
void UnsubscribeNode(ObserverNode<T> node);
}
internal sealed class ObserverNode<T> : IObserver<T>, IDisposable
{
private readonly IObserver<T> observer;
private IObserverLinkedList<T> list;
@0xF6
0xF6 / half-cpu.sh
Last active August 26, 2023 20:13
force half cpu power for homemade servers when main work PC is offline
if ping -c 1 10.10.10.254 &> /dev/null
then
if [ ! -f /tmp/cpu.up.status ]; then
cpupower frequency-set -u 3200Mhz
touch /tmp/cpu.up.status
if [ -f /tmp/cpu.down.status ]; then
rm -rf /tmp/cpu.down.status
fi
fi
else
@0xF6
0xF6 / enumCache.cs
Created July 30, 2023 18:36
EnumCache Class with MaxValue\MinValue underlying number
public static class EnumCache<T>
{
public class Cache<X>
{
public Array Values { get; }
public object[] UnderlyingValues { get; }
public int TotalValues { get; }
public Type UnderlyingType { get; }
public Type SelfType => typeof(X);
@0xF6
0xF6 / Fluidsim.cs
Created December 31, 2022 08:51
unity and burst
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.Burst;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
public unsafe class FluidSystem : IFluidSystem, IDisposable
{
# dec/14/2022 04:17:05 by RouterOS 7.7rc1
# software id = XH5D-E1DZ
#
# model = RB2011UiAS-2HnD
# serial number = HCN087QV7D1
/interface bridge add admin-mac=18:FD:74:20:D9:C2 auto-mac=no comment=defconf name=bridge
/interface wireless set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX disabled=no distance=indoors frequency=auto installation=indoor mode=ap-bridge ssid="BlackBox 2G" wireless-protocol=802.11
/interface list add comment=defconf name=WAN
/interface list add comment=defconf name=LAN
/interface wireless security-profiles set [ find default=yes ] authentication-types=wpa2-psk mode=dynamic-keys supplicant-identity=MikroTik
@0xF6
0xF6 / fucking_grid_to_sphere.cs
Created November 3, 2022 12:33
Generate grid and cast to cubesphere side
public void Generate(Vector3 localUp = Vector3.up)
{
var axisA = new Vector3(localUp.y, localUp.z, localUp.x);
var axisB = Vector3.Cross(localUp, axisA);
for (var y = 0; y < Resolution; y++)
for (var x = 0; x < Resolution; x++)
{
var percent = new Vector2(x, y) / (Resolution - 1);
var pointOnUnitCube = localUp + (percent.x - .5f) * 2 * axisA + (percent.y - .5f) * 2 * axisB;
@0xF6
0xF6 / SplashScreen.cs
Last active September 10, 2022 11:11
native splash screen when using native aot without wpf or win forms
using System.ComponentModel;
using static NativeApi;
public class SplashScreen : IDisposable
{
private ushort _wndClass;
private IntPtr _hwnd;
private const string CLASS_NAME = "SplashScreen";
private Bitmap _bitmap;
private static HandleRef nullHandle = new HandleRef(null, IntPtr.Zero);
private WndProc? proc;