Skip to content

Instantly share code, notes, and snippets.

View oliverbooth's full-sized avatar
🔷
Reticulating splines

Oliver Booth oliverbooth

🔷
Reticulating splines
View GitHub Profile
bool CollisionTest()
{
var aRectangle = new Rectangle(_a.X, _a.Y, _a.Width, _a.Height);
var bRectangle = new Rectangle(_b.X, _b.Y, _b.Width, _b.Height);
return Intersects(aRectangle, bRectangle);
}
bool Intersects(Rectangle a, Rectangle b)
{
@oliverbooth
oliverbooth / Behaviour.cs
Last active January 3, 2024 23:24
A barebones recreation of Unity's coroutine system, complete with an example behaviour.
using System.Collections;
public abstract class Behaviour
{
private readonly List<Stack<IEnumerator>> _activeCoroutines = new();
public virtual void Start()
{
}
@oliverbooth
oliverbooth / PlayerBehaviour.cs
Last active April 27, 2021 13:30
Complete PlayerBehaviour & SaveData example
using System.IO;
using ProtoBuf;
using ProtoBuf.Meta;
using UnityEngine;
public class PlayerBehaviour : MonoBehaviour
{
private string _saveFile;
[field: SerializeField]
@oliverbooth
oliverbooth / RandomExtensions.cs
Last active March 10, 2021 10:12
A set of extension methods for System.Random to mimic the behaviour of UnityEngine.Random
using UnityEngine;
using Random = System.Random;
public static class RandomExtensions
{
public static Vector2 NextOnUnitCircle(this Random random)
var angle = random.NextSingle(0, 360f) * Mathf.Deg2Rad;
var x = Mathf.Cos(angle);
var y = Mathf.Sin(angle);
// ==UserScript==
// @name Phasmophobia Evidence Tracker Enhanced
// @version 1
// @namespace https://phasmophobiatracker.site/
// @run-at document-start
// ==/UserScript==
const addJQuery = function(callback) {
const script = document.createElement('script');
script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
public static void Main() {
FizzBuzz(100, new[]{("Fizz",3),("Buzz",5)});
}
public static void FizzBuzz(int c, (string,int)[] d) {
bool f(int n, int d)=>n%d==0;
for (int i=1;i<=c;i++) {
bool p=false;
for (int m=0;m<d.Length;m++) {
@oliverbooth
oliverbooth / FloatObject
Created April 2, 2020 03:42
Floating-like objects using UAssembly by VRChat
.data_start
.export amplitude
.export frequency
.sync x, smooth
.sync y, smooth
Vector3_tmp: %UnityEngineVector3, null
instance_0: %UnityEngineTransform, this
amplitude: %SystemSingle, 0.25
frequency: %SystemSingle, 1
/// <summary>
/// Calculates the Ackerman function for two values.
/// </summary>
/// <param name="m">The first value.</param>
/// <param name="n">The second value.</param>
/// <returns>Returns the result of the Ackerman function.</returns>
int Ackerman(int m, int n)
{
if (m == 0)
{
@oliverbooth
oliverbooth / .htaccess
Created January 15, 2017 06:19
htaccess snippet for forcing HTTPS through TLS/SSL on remote-only access
# Force HTTPS
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REMOTE_ADDR} !127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
RewriteCond %{REMOTE_ADDR} !localhost
RewriteCond %{REMOTE_ADDR} !::1
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
@oliverbooth
oliverbooth / ip-hotstring.ahk
Last active December 15, 2016 00:43
AutoHotkey hotstring for dumping your remote IP (using ipify)
; //ip macro by default - feel free to change this
; to whatever suits you best
;
; Oliver Davenport
:://ip::
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
; default format from ipify api is text/plain