Skip to content

Instantly share code, notes, and snippets.

View sgarcia22's full-sized avatar

Sam Garcia sgarcia22

View GitHub Profile
@hasanbayatme
hasanbayatme / Singleton.cs
Last active March 5, 2023 19:06
Best Singleton implementation in Unity, Combine it with preload scene pattern to achieve best implementation.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Singleton<T> : MonoBehaviour where T : Component
{
#region Fields
/// <summary>
@miketucker
miketucker / FXWaterPro.cs
Created February 19, 2017 22:21
Unity Water with VR support
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "FX/Water" {
Properties {
_WaveScale ("Wave scale", Range (0.02,3.0)) = 0.063
_ReflDistort ("Reflection distort", Range (0,1.5)) = 0.44
_RefrDistort ("Refraction distort", Range (0,1.5)) = 0.40
_Brightness("Brightness", Range(0,1.0)) = 0.40
_RefrColor ("Refraction color", COLOR) = ( .34, .85, .92, 1)
[NoScaleOffset] _Fresnel ("Fresnel (A) ", 2D) = "gray" {}
@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active April 22, 2025 15:34
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@kbendick
kbendick / mergesort.cpp
Created March 8, 2016 19:44
Implementation of merge sort in c++
// Declare/initialize any useful variables here, including the temporary array
// to merge values into and then copy back into the parameter array.
/*
while the temporary array is not filled
if there are no more values in the left part of a,
move next value from right part of a into next index of the temporary array otherwise, if there are no more values in the right part of a,
move next value from left part of a into next index of the temporary array otherwise (values in each part) compare the first value in each part
move smallest value from a into next index of the temporary array
@n3dst4
n3dst4 / renaming.markdown
Last active January 13, 2025 16:46
How to rename Visual Studio solutions and projects

How to rename solutions and projects in Visual Studio

  1. Don't.

How to rename solutions and projects that were created in Visual Studio

  1. Close Visual Studio and don't open it again until I tell you. Visual Studio is not competent at renaming things.
  2. Assuming you're using git, clean the working folder to remove anything that's not in version control (this will help the search-and-replace step because it won't have to go through a bunch of generated files)

git clean -fdx

@mstevenson
mstevenson / MonoBehaviourSingleton.cs
Created December 18, 2012 04:51
Generic Singleton classes for Unity. Use MonoBehaviourSingletonPersistent for any singleton that must survive a level load.
using UnityEngine;
using System.Collections;
public class MonoBehaviourSingleton<T> : MonoBehaviour
where T : Component
{
private static T _instance;
public static T Instance {
get {
if (_instance == null) {