Skip to content

Instantly share code, notes, and snippets.

Avatar

Slipp Douglas Thompson capnslipp

View GitHub Profile
@capnslipp
capnslipp / DisableWhenAttribute.cs
Last active Jun 3, 2020
ShowWhen, HideWhen, EnableWhen, & DisableWhen Attributes for #Unity3D
View DisableWhenAttribute.cs
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: Shows a field as disabled in Unity's Inspector only when a different method/property/field in the same MonoBehaviour returns/is-equal-to a given value or values.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Add `[DisableWhen(typeof(«MonoBehaviour-sub-type-name»), "«trigger-member-name»", «value-that-the-trigger-member-returns»)]` attribute to a (serializable public) field on your `MonoBehaviour`-class.
/// @intended project path: Assets/Plugins/EditorUtils/DisableWhenAttribute.cs
/// @interwebsouce: https://gist.github.com/capnslipp/9b99f83aa7b80dfb589a5b23e8e0cfa0
using System;
using UnityEngine;
@capnslipp
capnslipp / StringIndexOffsetExtensions_Playground.swift
Last active Apr 20, 2017
Swift String extensions for shorthand (Ruby-like) indexing
View StringIndexOffsetExtensions_Playground.swift
//: Playground - noun: a place where people can play
import Swift
var str = "Hello, playground"
extension String
{
func index(atOffset offset:String.IndexDistance) -> String.Index {
@capnslipp
capnslipp / Full-width content.css
Last active Dec 2, 2016
Userstyle CSS for developer.apple.com/reference/*
View Full-width content.css
@-moz-document url-prefix("http://developer.apple.com/reference/"), url-prefix("https://developer.apple.com/reference/") {
.section-content {
margin-left: 4rem !important;
margin-right: 4rem !important;
width: auto !important;
}
.topic-description, .topic-content {
width: auto !important;
float: none !important;
View keybase.md

Keybase proof

I hereby claim:

  • I am capnslipp on github.
  • I am capnslipp (https://keybase.io/capnslipp) on keybase.
  • I have a public key whose fingerprint is 6D3E 4ADE 0891 6852 A4AB 52A8 9D4B D9DA FAB9 13D1

To claim this, I am signing this object:

@capnslipp
capnslipp / SCNViewController.swift
Last active Sep 18, 2016
An adaptable UIViewController subclass for SceneKit
View SCNViewController.swift
/// @creator: Slipp Douglas Thompson
/// @license: WTFPL
/// @purpose: A `UIViewController` subclass (instantiable from code or XIB/Storyboard) that initializes its `SCNView` using the specified `viewFrame` & `viewOptions`.
/// @why: Because this functionality should be built-into SceneKit.
/// @usage: _FILL_IN_
/// @interwebsouce: https://gist.github.com/capnslipp/6d3e4d3a5f0aeb96eda416774e22dd1f
import UIKit
import SceneKit
@capnslipp
capnslipp / NilCoalescingAssignmentOperators.swift
Last active Feb 6, 2017
Swift extension for `=??` and `??=` nil-coalescing-assignment operators
View NilCoalescingAssignmentOperators.swift
/// @creator: Slipp Douglas Thompson
/// @license: WTFPL
/// @purpose: A concise operator syntax for assigning to a non-`Optional` from an `Optional`.
/// @why:
/// Sometimes in Swift you want to assign only if the RHS is non-`nil`.
/// Say you have `someArg:Int?` and `_someIvar:Int`. You could use a single-line `if`:
/// `if someArg != nil { _someIvar = someArg! }`
/// Or you could use a ternary or nil-coalesce:
/// `_someIvar = someArg != nil ? someArg! : _someIvar`
/// `_someIvar = someArg ?? _someIvar`
@capnslipp
capnslipp / GlobalsStruct.swift
Last active Jul 23, 2016
Swift struct private init() test
View GlobalsStruct.swift
public struct GlobalsStruct {
public static let aValue = 5
private init() {}
}
@capnslipp
capnslipp / CodeWithDifferingIntentsShouldLookDifferent.swift
Last active Jun 8, 2016
My preferred code style for colons in Swift (following good coding habits learned long ago).
View CodeWithDifferingIntentsShouldLookDifferent.swift
import Foundation
class Example {
static func method(label argName:String) -> Void {
NSLog(argName)
}
}
class SuperClass {}
class AType {
@capnslipp
capnslipp / NonDrawingGraphic.cs
Last active Jun 22, 2021
A UnityEngine.UI.Graphic subclass that provides only raycast targeting, skipping all drawing.
View NonDrawingGraphic.cs
/// @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;
@capnslipp
capnslipp / .gitignore
Created Jan 30, 2016
Unity3D .gitignore
View .gitignore
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
# Autogenerated VS/MD solution and project files
*.csproj
*.unityproj
*.booproj
*.sln
*.user