Skip to content

Instantly share code, notes, and snippets.

View LuviKunG's full-sized avatar

Thanut Panichyotai LuviKunG

View GitHub Profile
@LuviKunG
LuviKunG / logic.js
Created January 5, 2023 23:25
My experiment of working on logic gates in Javascript.
var xor = (...args) => {
let x = [];
for (let i = 0; i < args.length; i++) {
let y = [];
for (let j = 0; j < args.length; j++)
y.push(i == j ? args[j] : !args[j]);
x.push(and(...y));
}
let w = and(...args);
return or(...x, w);
@LuviKunG
LuviKunG / install_apk.bat
Last active January 18, 2023 04:52
Batch file that easily to select the *.apk files in the directory and install via 'adb'.
@echo off
setlocal enabledelayedexpansion
set i=0
for %%f in (*.apk) do (
set /A i+=1
set apk[!i!]=%%f
)
echo Available APK files:
for /L %%i in (1,1,%i%) do echo [%%i] !apk[%%i]!
set /p index=Enter the index of the APK file you want to install:
@LuviKunG
LuviKunG / SecretOfGrindeaMathPuzzleSolver.cs
Last active March 11, 2023 15:02
This is Secrets of Grindea App Instance Main Class. Using for solve the endless math dungeon puzzle in the game.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LuviKunG
{
/// <summary>
/// This is Secrets of Grindea App Instance Main Class.
/// Using for solve the endless math dungeon puzzle in the game.
@LuviKunG
LuviKunG / TaskSchedulerExtensions.cs
Last active August 21, 2023 07:08
C# extension that helps async to callback main thread sync.
using System;
using System.Threading.Tasks;
namespace LuviKunG.Extensions
{
public static class TaskSchedulerExtensions
{
public static Task ContinueWithCurrentSynchronizationContext(this Task task, Action<Task> action)
{
return task.ContinueWith(action, TaskScheduler.FromCurrentSynchronizationContext());
@LuviKunG
LuviKunG / UserInterfaceBehaviour.cs
Created February 7, 2024 17:36
User Interface Behaviour. Inherit from this class to create a User Interface Behaviour which will have a reference to the RectTransform.
namespace UnityEngine
{
using EventSystems;
/// <summary>
/// User Interface Behaviour.
/// Inherit from this class to create a User Interface Behaviour
/// which will have a reference to the <see cref="RectTransform"/>.
/// </summary>
public abstract class UserInterfaceBehaviour : UIBehaviour
@LuviKunG
LuviKunG / FSMException.cs
Created February 7, 2024 18:39
Simple and easy to use of state machines.
using System;
using System.Runtime.Serialization;
namespace LuviKunG.FSM
{
/// <summary>
/// Exception for the state machine.
/// </summary>
public class FSMException : Exception
{
@LuviKunG
LuviKunG / RichTextBlockInputActionDecorator.cpp
Last active April 3, 2024 04:18
Unreal Engine: Display the input action prompt sprite in Rich Text Block depend on binding of input action key mapping of Enhanced input system.
// Copyright by Thanut Panichyotai (@LuviKunG)
// CC BY-SA 4.0
// https://creativecommons.org/licenses/by-sa/4.0/
#include "Widgets/RichTextBlockInputActionDecorator.h"
#include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h"
#include "Fonts/FontMeasure.h"
#include "Kismet/GameplayStatics.h"
@LuviKunG
LuviKunG / Obfuscator.cs
Created May 13, 2024 01:41
Simple obfuscator.
namespace LuviKunG
{
static class Obfuscator
{
/// <summary>
/// Obfuscate string with key.
/// </summary>
/// <param name="key">Key to obfuscate.</param>
/// <param name="str">String to obfuscate.</param>
/// <returns>Obfuscated byte array.</returns>
@LuviKunG
LuviKunG / AssetDatabaseHelper.cs
Last active May 19, 2024 15:10
Unity Editor static class for asset database operations.
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace LuviKunG.Editor
{
using UnityObject = UnityEngine.Object;
/// <summary>
@LuviKunG
LuviKunG / ObjectPickerEditorWindow.cs
Last active May 19, 2024 15:11
Unity editor window that used to pick an object from the asset database such as scriptable objects or prefabs which contains specific component.
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace LuviKunG.Editor
{
using UnityObject = UnityEngine.Object;
/// <summary>