Skip to content

Instantly share code, notes, and snippets.

@drscotthawley
drscotthawley / greenscreen.py
Last active December 10, 2021 07:21
greenscreen.py: Greenscreen effect without a physical green screen, via OpenCV and Python
#! /usr/bin/env python
'''
greenscreen.py: Greenscreen effect without a physical green screen
This performs background subtraction, and sets the background to "green" for use with "key frame" video editing software
Author: Scott Hawley, https://github.com/drscotthawley
Requirements:
Python, NumPy and OpenCV
I got these via Macports, but Homebrew, etc. work.
@capnslipp
capnslipp / NonDrawingGraphic.cs
Last active April 20, 2024 17:48
A UnityEngine.UI.Graphic subclass that provides only raycast targeting, skipping all drawing.
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: A UnityEngine.UI.Graphic subclass that provides only raycast targeting, skipping all drawing.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Add a `NonDrawingGraphic` component to the GameObject you want clickable, but without its own image/graphics.
/// @intended project path: Assets/Plugins/UnityEngine UI Extensions/NonDrawingGraphic.cs
/// @interwebsouce: https://gist.github.com/capnslipp/349c18283f2fea316369
using UnityEngine;
using UnityEngine.UI;
@bkaradzic
bkaradzic / orthodoxc++.md
Last active April 23, 2024 13:59
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@shayded-exe
shayded-exe / ScriptableObjectPropertyDrawer.cs
Last active September 4, 2020 15:12
Put this script in your Editor folder. Then right click on any inspector field that accepts a ScriptableObject to create an asset for it. The asset will also automatically be assigned to the field.
using System;
using System.IO;
using System.Linq;
using System.Linq.Extensions;
using UnityEditor;
using UnityEngine;
namespace PachowStudios.BadTummyBunny.Editor
{
[CustomPropertyDrawer(typeof(ScriptableObject), true)]
#pragma once
// This provides a library for stubbing and mocking C++ code as is. It works by requiring
// explicit hooks to be inserted into the code that is to be mocked. In a regular build,
// these hooks will do nothing. In a testing build, they will expand to calls into the
// framework here to allow the code being executed to be hijacked from outside.
//
// NOTE: Thread-safety! Arranging fakes must be done on a single thread. Using fakes can
// be done from multiple threads concurrently.
//
@samgro
samgro / FSQSplitViewController.h
Last active July 13, 2016 01:27
FSQSplitViewController
//
// FSQSplitViewController.h
//
// Copyright (c) 2015 Foursquare. All rights reserved.
//
#import "FSCoreViewController.h"
NS_ASSUME_NONNULL_BEGIN;
@jaibeee
jaibeee / brew-perms.sh
Last active February 15, 2024 22:49
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
@capnslipp
capnslipp / GameObjectFindComponentExtension.cs
Last active June 20, 2023 13:06
Unity3D MonoBehaviourPopulateExtension & friends
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: More-flexible GO-tree searching for Components by type, configurable via `SearchExtent` enum arg.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Call `this.gameObject.FindComponent<«component-type»>(«SearchExtent-type»);`.
/// @intended project path: Assets/Plugins/UnityEngine Extensions/GameObjectFindComponentExtension.cs
/// @interwebsouce: https://gist.github.com/capnslipp/ac26e38fce770b5c4594
using System;
using UnityEngine;
@piaoger
piaoger / test_mmap_ios.m
Last active July 8, 2020 18:34
mmap on ios
// It's tested on ios 8.2 ..
// Apple document about virtual memory:
// Both OS X and iOS include a fully-integrated virtual memory system that you cannot turn off; it is always on.
// https://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html
// Discussing mmap on ios:
// http://stackoverflow.com/questions/13425558/why-does-mmap-fail-on-ios
// http://stackoverflow.com/questions/9184773/is-there-a-practical-limit-on-the-number-of-memory-mapped-files-in-ios
#include <sys/mman.h>
@capnslipp
capnslipp / KeyedEventActionForwarder.cs
Last active December 5, 2019 15:47
SingleEventAction, KeyedEventActions, & Friends
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: Forwards keyed events to a KeyedEventActions component elsewhere.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Needs to be put on the same GameObject as the Mecanim Animator component or “legacy” Animation component.
/// Animation events should be configured in the Unity Editor's Animation timeline view or model import settings › Animations tab › Events disclosure (or via the scripting API, I suppose) to call “Function: Action, Parameter String: «your-decided-key-string-for-this-action»”.
/// @intended project path: Assets/Utils/EventAction/KeyedEventActionForwarder.cs
/// @interwebsouce: https://gist.github.com/capnslipp/50db1dc724514bb3db91
using System;