Skip to content

Instantly share code, notes, and snippets.

View marutypes's full-sized avatar
💻
Virtualizing your realities

Mallory Allen marutypes

💻
Virtualizing your realities
View GitHub Profile
@marutypes
marutypes / LootLocker.gd
Last active September 25, 2023 11:33
Godot Lootlocker Example
# No class_name because we autoload this!
extends Node
const GAME_KEY = "YOUR_KEY"
const GAME_VERSION = "0.0.1"
const AUTH_URL = "https://api.lootlocker.io/game/v2/session/guest"
const LEADERBOARD_URL = "https://api.lootlocker.io/game/YOUR_LEADERBOARD_KEY/highscores/list?count=10"
const SET_NAME_URL = "https://api.lootlocker.io/game/player/name"
const SUBMIT_SCORE_URL = "https://api.lootlocker.io/game/YOUR_LEADERBOARD_KEY/highscores/submit"
Shader "Debugger"
{
Properties
{
[HideInInspector] _texcoord( "", 2D ) = "white" {}
}
Subshader
{
Tags { "RenderType" = "Opaque" }
CGPROGRAM
@marutypes
marutypes / FolderStructureSetup.cs
Last active January 21, 2024 19:10
Unity Directory Bootstrapper
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.IO;
public class FolderStructureSetup
{
[MenuItem("Tools/Setup Project Structure")]
private static void SetupProjectFolders()
{
@marutypes
marutypes / Singleton.cs
Created July 1, 2023 19:46
Unity Singleton base classes with networked variants
using Unity.Netcode;
using UnityEngine;
/// <summary>
/// Singleton base class for normal MonoBehaviours
/// </summary>
public class Singleton<T> : MonoBehaviour where T : Component
{
public static T Instance { get; private set; }
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.s status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.undo 'reset HEAD~1 --mixed'
git config --global alias.done 'push origin HEAD'
git config --global alias.unfuck 'reset --hard'
git config --global alias.d diff
@marutypes
marutypes / EventEmitter.ts
Created December 2, 2020 18:29
A simple naive TS event emitter, useful for making nice typed events without remembering how to do it every time
type EventMap = Record<string, any>;
type EventKey<T extends EventMap> = string & keyof T;
type Callback<T> = (params: T) => void;
export class EventEmitter<T extends EventMap> {
private listeners: {
[K in keyof EventMap]?: Array<(p: EventMap[K]) => void>;
} = {};
on<K extends EventKey<T>>(key: K, fn: Callback<T[K]>) {
@marutypes
marutypes / gitmoji.md
Last active March 12, 2022 20:38
Mallen's Simplified Gitmoji

Mallen's Simplified Gitmoji

Inspired by gitmoji, stripped down to an easier to remember and less granular subset. Include these in your commits and PR titles to enhance you communication and mood.

  • 🎉 :tada: first commit
  • :sparkles: adds a feature
  • 💥 :boom: breaking change
  • 📝 :memo: adds docs
  • :heavy_plus_sign: adds dependency(s)
  • :heavy_minus_sign: removes dependency(s)
@marutypes
marutypes / thing.md
Last active August 20, 2019 20:30
SK ❤️ Rails hackdays announcement thing

Hey folks!

TLDR: Preview the future of React SSR in Rails apps today, give us your beautiful feedback gifts ;)

The Web Foundation team has some new tools we're ready for teams to put it through their paces during hack days. Over the last few weeks we’ve been working away at pushing the boundaries of our support for Rails+React apps, and one the major fruits of this endeavor has been a brand new first-class pattern for Server-Side-Rendering React in Rails applications. We’ve written a handy new guide for getting setup from scratch, a gem with a built-in generator and a ready-to-install embedded app sample application.

As you may expect, though we are confident that this approach is the right choice going forward, this is still early days for the pattern so pop into #web-foundation-tech for support with whatever issues you may have.

We encourage you to try out SSR in your Rails+React hackdays project, but even if you stick with Client-Side-Rendering, you’ll find improved support with the new `sewing-kit

@marutypes
marutypes / set.js
Last active November 1, 2018 16:17
set
// assuming keypath is string | number array like `['foo', 0, 'bar']`
export function set(object, keypath, value) {
if (keypath.length === 0) {
return value;
}
const segments = keypath.slice(0, -1);
const finalSegment = keypath.slice(-1)[0];
const leaf = segments.reduce((node, key) => {
@marutypes
marutypes / node-gc-debug-flags
Created October 29, 2018 14:38
node garbage collection tracing flags
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--trace_gc (print one trace line following each garbage collection)
type: bool default: false
--trace_gc_nvp (print one detailed trace line in name=value format after each garbage collection)
type: bool default: false
--trace_gc_ignore_scavenger (do not print trace line after scavenger collection)
type: bool default: false