Skip to content

Instantly share code, notes, and snippets.

View smbss1's full-sized avatar
🏠
Working from home

Softands smbss1

🏠
Working from home
View GitHub Profile
@smbss1
smbss1 / ProjectSetup.cs
Created August 19, 2025 21:05 — forked from adammyhre/ProjectSetup.cs
Automated Unity Project Setup Script
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;
using static System.Environment;
@smbss1
smbss1 / try-catch.ts
Created March 25, 2025 22:13 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@smbss1
smbss1 / every-vm-tutorial-you-ever-studied-is-wrong.md
Created September 30, 2024 20:05 — forked from o11c/every-vm-tutorial-you-ever-studied-is-wrong.md
Every VM tutorial you ever studied is wrong (and other compiler/interpreter-related knowledge)

Note: this was originally several Reddit posts, chained and linked. But now that Reddit is dying I've finally moved them out. Sorry about the mess.


URL: https://www.reddit.com/r/ProgrammingLanguages/comments/up206c/stack_machines_for_compilers/i8ikupw/ Summary: stack-based vs register-based in general.

There are a wide variety of machines that can be described as "stack-based" or "register-based", but not all of them are practical. And there are a lot of other decisions that affect that practicality (do variables have names or only address/indexes? fixed-width or variable-width instructions? are you interpreting the bytecode (and if so, are you using machine stack frames?) or turning it into machine code? how many registers are there, and how many are special? how do you represent multiple types of variable? how many scopes are there(various kinds of global, local, member, ...)? how much effort/complexity can you afford to put into your machine? etc.)

  • a pure stack VM can only access the top elemen
@smbss1
smbss1 / vm-profile.nix
Created September 29, 2024 06:29 — forked from joshleecreates/vm-profile.nix
NixOS VM Profile
{ config, pkgs, modulesPath, lib, system, ... }:
{
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
config = {
#Provide a default hostname
networking.hostName = lib.mkDefault "base";
@smbss1
smbss1 / docker-compose.yml
Created June 22, 2024 15:53 — forked from Webreaper/docker-compose.yml
Sample Docker-compose file which shows how to set up Sonarr, Radarr, Prowlarr, Lidarr, QBittorrent and a VPN container so that all all traffic from the containers is routed through the VPN. Also includes Plex and get_iplayer containers, which are not routed through the VPN.
# Docker compose to set up containers for all services you need:
# VPN
# Sonarr, Radarr, Lidarr, Qbittorrent
# Non-VPN
# Plex, get_iplayer
# Before running docker-compose, you should pre-create all of the following folders.
# Folders for Docker State:
# /volume1/dockerdata. - root where this docker-compose.yml should live
# /volume1/dockerdata/plex - Plex config and DB
# /volume1/dockerdata/sonarr - Sonarr config and DB
@smbss1
smbss1 / store.ts
Created May 20, 2024 07:25 — forked from serifcolakel/store.ts
Make global state management with useSyncExternalStore hook. Idea from Jotai. i'm calling jotai-clone for this approach. Finally, i'm try on my side project it works very well :)
/**
* full article about this gist
* @link https://blog.stackademic.com/building-a-state-management-system-with-react-86d382fa33cd
*/
import { useSyncExternalStore } from 'react';
/**
* @description An atom is a unit of state in Jotai. It is a container of a value that can be read synchronously and updated asynchronously.
*/
Netcode package:
com.unity.netcode.gameobjects
Mutiplayer helpers (ClientNetworkTransform):
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main
ParrelSync:
https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync
@smbss1
smbss1 / SaveClient.cs
Created March 17, 2023 08:16 — forked from Matthew-J-Spencer/SaveClient.cs
SaveClient.cs
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Unity.Services.CloudSave;
using UnityEngine;
public class CloudSaveClient : ISaveClient
{
private readonly ICloudSaveDataClient _client = CloudSaveService.Instance.Data;
@smbss1
smbss1 / ToonTerrain.cginc
Created January 24, 2023 01:40 — forked from probablyspoonie/ToonTerrain.cginc
Toon Terrain Tutorial
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Edits by Glynn Taylor. MIT license
// Includes code for splitmap by https://twitter.com/adamgryu and triplanar mapping by https://github.com/keijiro. MIT License
#ifndef TERRAIN_SPLATMAP_COMMON_CGINC_INCLUDED
#define TERRAIN_SPLATMAP_COMMON_CGINC_INCLUDED
struct Input
{
float3 localNormal : TEXCOORD0;
@smbss1
smbss1 / AIController.cs
Created July 19, 2022 05:07
Unity Utility Based AI Setup
using System.Collections.Generic;
using UnityEngine;
namespace UGPXFramework {
public class AIController {
private DynamicBlackboard _blackboard = new DynamicBlackboard();
private List<IAIScan> _scans = new List<IAIScan>();
private List<IAIAction> _actions = new List<IAIAction>();
public AIController(GameObject gameObject) {