Skip to content

Instantly share code, notes, and snippets.

//https://gist.github.com/col000r/6658520
//but all the hard work done by mstevenson: https://gist.github.com/mstevenson/4050130
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ShuffleBag<T> : ICollection<T>, IList<T>
{
private List<T> data = new List<T> ();
@twobob
twobob / MonoBehaviourSingleton.cs
Created April 15, 2017 03:05 — forked from mstevenson/MonoBehaviourSingleton.cs
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) {
@twobob
twobob / CreateQuadMesh.cs
Created April 15, 2017 03:05 — forked from mstevenson/CreateQuadMesh.cs
Create a quad mesh asset in Unity. Place this script in the Editor folder.
using System;
using UnityEngine;
using UnityEditor;
public class CreateQuadMesh : Editor {
[MenuItem("Assets/Create/Quad Mesh", false, 10000)]
public static void Create ()
{
Mesh mesh = BuildQuad (1, 1);
@twobob
twobob / Reticle.cs
Created April 15, 2017 03:06
Demonstration of a screen-centered reticle in Unity
using UnityEngine;
using System.Collections;
public class Reticle : MonoBehaviour
{
public Texture2D reticle;
void Awake ()
{
// Set up reticle
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class PolyPri : MonoBehaviour
{
void Start ()
{
MeshFilter[] myMeshs = FindObjectsOfType (typeof(MeshFilter)) as MeshFilter[];
@twobob
twobob / InputEvents.cs
Created April 15, 2017 03:18 — forked from mstevenson/InputEvents.cs
Bind key presses to methods in Unity at runtime
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public delegate void InputKeyDelegate (KeyCode key);
public delegate void InputAxisDelegate (string name,float value);
public class InputEvents : MonoBehaviour
{
@twobob
twobob / Instruments.cs
Created April 15, 2017 03:18 — forked from mstevenson/Instruments.cs
Unity tool for measuring execution time
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Debugging tools
/// </summary>
public static class Instruments
{
static string stopwatchName;
@twobob
twobob / FindReferences.cs
Created April 15, 2017 03:18 — forked from mstevenson/FindReferences.cs
Find Unity objects that reference a selected asset
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class FindReferences : EditorWindow, ISerializationCallbackReceiver
{
List<string> displayedRefs = new List<string>();
@twobob
twobob / clarifai_local_image_tagging.py
Last active May 20, 2017 18:44 — forked from devStepsize/clarifai_local_image_tagging.py
Local image tagging with Clarifai's Python client
import os
from os.path import expanduser
import glob
from clarifai import rest
from clarifai.client import ClarifaiApi
app = ClarifaiApi()
directory = expanduser('~/pictures/clarifai/')
txts=glob.glob1(directory, "*.tx?")
jpgs=glob.glob1(directory, "*.JPG")
txts = [suffix.replace('.JPG.txt', '.JPG') for suffix in txts]
@twobob
twobob / web-servers.md
Created May 12, 2017 03:32 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000