Skip to content

Instantly share code, notes, and snippets.

@capnslipp
capnslipp / .gitignore
Created January 30, 2016 23:30
Unity3D .gitignore
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
# Autogenerated VS/MD solution and project files
*.csproj
*.unityproj
*.booproj
*.sln
*.user
@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;
@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;
#!/usr/local/bin/node
var https = require('https');
var token, username;
var tenxer = 'tenxer';
var shitsFucked = 0;
var shitsUnfucked = 0;
var reposCount = 0;
process.argv.forEach(function (arg) {
@capnslipp
capnslipp / cssarrowsplease.less
Created October 22, 2014 07:32
An attempt to port cssarrowplease.com to a Less mixin in order to make the if/else approach in http://hugogiraudel.com/2012/11/13/less-to-sass/ look dumb
@arrow_box_size: 30px;
@arrow_box_color: #88b7d5;
@arrow_box_border_width: 4px;
@arrow_box_border_color: #c2e1f5;
.arrow_box {
position: relative;
background: @arrow_box_color;
border: @arrow_box_border_width solid @arrow_box_border_color;
&:after, &:before {
@capnslipp
capnslipp / Texture Stepped.glsl.shader
Created August 23, 2014 08:10
Fragment-phase texture point-filtering, as a Unity GLSL shader
/// @creator: Slipp Douglas Thompson
/// @license: WTFPL
/// @why: Too trivial to care.
/// @intersource: https://gist.github.com/capnslipp/02536fd06afe9428c381
Shader "Texture Stepped" {
Properties {
_MainTex ("Base (RGBA)", 2D) = "gray" {}
_Step ("Step (XY)", Vector) = (32, 32, 0, 0)
}
@capnslipp
capnslipp / RectOffsetPOD.cs
Last active December 5, 2019 15:51
RectOffsetPOD for Unity3D (since UnityEngine.RectOffset likes to throw “ArgumentException: set_left can only be called from the main thread.” if used as a field initialier)
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @why: Because UnityEngine.RectOffset fields should be able to be initialized without throwing ArgumentExceptions (last observed 4.5.2f1).
/// Also, UnityEngine.RectOffset should probably be a struct, not a class.  So a struct form like this is necessary for some software patterns.
/// @intended project path: Assets/Plugins/UnityEngine Extensions/RectOffsetPOD.cs
/// @intersource: https://gist.github.com/capnslipp/87d944e474ca701eca8b
using System;
using UnityEngine;
@capnslipp
capnslipp / TestLateFixedUpdate.cs
Created May 18, 2014 01:19
Unity LateFixedUpdate pattern test script
using UnityEngine;
using System.Collections;
public class TestLateFixedUpdate : MonoBehaviour
{
void OnEnable() {
StartCoroutine("RunLateFixedUpdate");
}
@capnslipp
capnslipp / AppDelegateLoudspeaker.cs
Last active December 5, 2019 15:53
iOS AppDelegate UINotifications, in Unity MonoBehaviour scripts
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @why: Because this functionality should be built-into Unity.
/// @intended project path: Assets/Plugins/iOS-Bridge/AppDelegateLoudspeaker.cs
/// @intersource: https://gist.github.com/capnslipp/036f7c98f5ccf42e8428
using UnityEngine;
@capnslipp
capnslipp / git-list-dupe-commits
Last active January 12, 2023 23:27
A small, inefficient, naïvely-written bash script to list all duplicate commits (those with the same patch-id) in a git repo.
#!/usr/bin/env bash
test ! -z "$1" && TARGET_COMMIT_SHA="$1" || TARGET_COMMIT_SHA="HEAD"
TARGET_COMMIT_PATCHID=$(
git show --patch-with-raw "$TARGET_COMMIT_SHA" |
git patch-id |
cut -d' ' -f1
)
MATCHING_COMMIT_SHAS=$(