Skip to content

Instantly share code, notes, and snippets.

View 0xF6's full-sized avatar
🧬

Yuuki Wesp 0xF6

🧬
View GitHub Profile
@0xF6
0xF6 / AdBannerSafeRegion.cs
Last active November 2, 2020 19:31
Apply a safe region calculation using classic ad banner.
/// <summary>
/// Only <see cref="BannerPosition.BOTTOM_*"/>
/// </summary>
public static void ApplyAdsSafeRegion(this RectTransform target, Rect safeRegion)
{
static float getAdHeight() =>
((Screen.height / (Screen.dpi / 160f)) > 720f) ? 90f * (Screen.dpi / 160f)
: ((Screen.height / (Screen.dpi / 160f)) > 400f) ? 50f * (Screen.dpi / 160f)
: 32f * (Screen.dpi / 160f);
r.y += getAdHeight();
@0xF6
0xF6 / method.regex
Created January 23, 2021 19:40
rex for method declaration
(?x)
(?<return-type>
(?<type-name>
(?:
(?:ref\s+(?:readonly\s+)?)?
(?:
(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)?
(?<name-and-type-args>
\g<identifier>\s*
(?<type-args>\s*<(?:[^<>]|\g<type-args>)+>\s*)?
@0xF6
0xF6 / auto_craft.ahk
Created January 29, 2021 10:32
Cyberpunk 2077 auto craft script
#MaxThreadsPerHotkey 3
F1::
Toggle := !Toggle
Loop
{
If (!Toggle)
Break
Click down
Sleep 850
@0xF6
0xF6 / easy_vm.cpp
Last active June 20, 2024 16:24
Minimal realization of Virtual Machine in C++
enum
{
NOP,
ADD
};
struct thestack {
union {
int i;
var rarity = new [] { 5000, 2000, 1000, 500, 100 };
int[] dispenser_action(int sum)
{
if (sum % rarity.OrderBy(x => x).First() != 0)
throw new Exception();
var result = new List<int>();
foreach (var r in rarity)
{
var x = (sum - (sum % r)) / r;
result.AddRange(Enumerable.Range(0, x).Select(_ => r));
@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")]
@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 / 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 / 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;
# 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