Skip to content

Instantly share code, notes, and snippets.

@petersvp
petersvp / ImagePreferredSizeScaler.cs
Last active February 20, 2024 06:31
A Layout Element controller to be added on an image within a Layout Group that can solve the height-for-width problem
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[ExecuteAlways]
public class ImagePreferredSizeScaler : MonoBehaviour, ILayoutElement
{
Image image;
public float scale = 1;
@petersvp
petersvp / HumanBenchmark-VerbalMemory-Bot.cpp
Created October 23, 2023 04:22
C++ bot that plays Verbal Memory in HumanBenchmark
#include <Windows.h>
#include <iostream>
#include "stdio.h"
#include <vector>
#include <set>
using namespace std;
// This is the time in ms when the program waits before taking a new screen shot
const int turnTime = 50;
@petersvp
petersvp / HumanBenchmark-ReactionTime-Bot.cpp
Created October 23, 2023 01:26
C++ bot that plays Reaction Time in HumanBenchmark
#include <Windows.h>
#include <iostream>
#include "stdio.h"
#include <vector>
using namespace std;
int main()
{
// Windows only!
@petersvp
petersvp / HumanBenchmark-SequenceMemory-Bot.cpp
Created October 23, 2023 00:10
C++ bot that plays Sequence Memory in HumanBenchmark
#include <Windows.h>
#include <iostream>
#include <vector>
#include "stdio.h"
using namespace std;
int main()
{
// for the memory game, colors
COLORREF background_color = 13731627;
#if UNITY_EDITOR
/// <summary>
/// Float field with NAN button so you can use optional floats in your Unity components
/// </summary>
public sealed class NaNField : PropertyAttribute {}
[CustomPropertyDrawer(typeof(NaNField))]
public sealed class NaNFloatField : PropertyDrawer
{
const int buttonWidth = 40;
@petersvp
petersvp / LibRawInput.cpp
Created September 1, 2022 12:24
Unity + RawInput: Multiple mice + pointers (C++ DLL + C# MonoBehaviour)
/* A RawInput implementation with HWND_MESSAGE window and Device State detection. Uses separate thread and accumulates deltas */
/* You need to compile this single cpp to "LibRawInput.dll" using C++ compiler of choice and Windows SDK. */
/* Then add the DLL to your Unity project as a native plugin. */
#include <atomic>
#include <Windows.h>
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <mutex>
@petersvp
petersvp / SteamQueryBatchKey.js
Created February 3, 2021 20:30
Batch Query Steam Keys for activation on SteamWorks
// 1. GO TO SteamWorks, into the Query CD Key page, here: https://partner.steamgames.com/querycdkey/
// 2. Fill in your keys below:
// 3. Go to DevTools, Console, and paste all of this here there!
// 4. Report will be printed to the console.
keys = `
0ZQR4-N0H7K-AEJ77
D05V5-P47AP-4ET3Q
GGJZ5-ZN0BR-F74C5
FWZP4-2IXHB-GYV3A