Skip to content

Instantly share code, notes, and snippets.

View d12's full-sized avatar
🐱

Nathaniel Woodthorpe d12

🐱
View GitHub Profile
@d12
d12 / foo.md
Created January 17, 2018 21:06
-          connection.relation.count("*")
+          connection.relation.count(:all)
@d12
d12 / hello.rb
Created March 12, 2019 14:46
HELLO
puts("Hello World")
@d12
d12 / notes.md
Created October 21, 2019 15:28
Ruby I/O

These are some notes that will help with the Repl.it assignment.

Input/Output

Getting input

string = gets.chomp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FloatingObject : MonoBehaviour
{
Rigidbody rb;
// Linearly scales the force of buoyancy
@d12
d12 / functions.js
Last active December 9, 2020 15:42
// Doesn't work
function Component(props: Props) {
[foo, setFoo] = useState<number>(0);
function useFoo() {
// Foo is always 0
console.log(foo);
}
return <>
@d12
d12 / vrinstall.sh
Created February 2, 2021 01:27
Installs an APK onto the quest
function vrinstall () {
FILE="filename.apk"
device_id=$(adb devices | head -2 | tail -1 | awk '{print $1}')
if [ -z $device_id ]
then
echo "No device plugged in."
sleep 1
vrinstall
else
@d12
d12 / Jiggle.cs
Last active March 11, 2021 13:53
Fixes issues caused by RealtimeTransform's sometimes dropping important updates
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// This class is needed because RealtimeTransforms use unreliable properties, which means sometimes
// packets are dropped. This normally isn't a big deal, unless your app relies on a single
// programmatic position update. If this single update is dropped, the position of the RealtimeTransform
// will appear very incorrect to other users, but correct to the RealtimeTransform owner.
//
// So to fix this, after a large update we enable the Jiggle script which will jiggle the object back and forth
@d12
d12 / quest-capture-fix.sh
Created March 9, 2021 19:17
Widen Oculus Quest recording capture size
set -e
adb shell setprop debug.oculus.capture.width 1280
adb shell setprop debug.oculus.textureWidth 1280
adb shell setprop debug.oculus.capture.height 720
adb shell setprop debug.oculus.capture.bitrate 10000000
adb shell setprop debug.oculus.foveation.level 0
adb shell setprop debug.oculus.capture.fps 60
@d12
d12 / realtimedictionary.md
Last active May 22, 2024 22:10
How to use RealtimeDictionary

I had trouble finding information or examples showing how to use RealtimeDictionary, so I put together this doc that details the things I learned as I figured it out.

What is a RealtimeDictionary

RealtimeDictionary isn't a generic C# dictionary that syncs across the network. It specifically maps from uints (unsigned ints, or integers from 0 to ~4 billion) to RealtimeModels. There are other guides which cover RealtimeModels, but they're essentially network-synced structs that can hold whatever data you like.

It's a little complicated if you were just looking to map between two primitive data types, but creating a small RealtimeModel that wraps a single attribute is pretty quick and easy.

Also note that your keys must be unsigned ints. RealtimeDictionary does not support keys of other types.

@d12
d12 / ExceptionManager.cs
Created March 29, 2021 01:26
A simple Unity exception handler that reports errors to a server. Handy for tracking down issues hit by end users.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExceptionManager : MonoBehaviour
{
private const int ExceptionsPerCooldown = 5;
private const float CooldownTime = 5f;
private int _exceptionsLeftBeforeTimeout = ExceptionsPerCooldown;