Skip to content

Instantly share code, notes, and snippets.

View 0xF6's full-sized avatar
🧬

Yuuki Wesp 0xF6

🧬
View GitHub Profile
@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;
@0xF6
0xF6 / hook.cs
Created September 10, 2022 09:29
public class HookFx<T> where T : Delegate
{
private readonly nint _original;
private readonly T _target;
private byte[] _originalByteCode = new byte[0];
private bool isInstalled;
public HookFx(nint original, T target)
{
_original = original;
_target = target;
@0xF6
0xF6 / CubemapTextureBuilder.cs
Created May 27, 2022 06:37 — forked from RemyUnity/CubemapTextureBuilder.cs
Unity utility to convert 6 texture to a single cubemap texture
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.IO;
public class CubemapTextureBuilder : EditorWindow
{
[MenuItem("Tools/Cubemap Builder")]