Skip to content

Instantly share code, notes, and snippets.

capnslipp / swift-build-driverkit
Last active December 29, 2022 17:58
Per-platform `swift-build-…` scripts
View swift-build-driverkit
#!/usr/bin/env bash
arch="$(uname -m)"
sdk_path="$(xcrun --sdk driverkit --show-sdk-path)"
sdk_version="$(xcrun --sdk driverkit --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-driverkit${sdk_version}" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-driverkit${sdk_version}" "$@"
capnslipp / DisableWhenAttribute.cs
Last active June 18, 2023 19:47
ShowWhen, HideWhen, EnableWhen, & DisableWhen Attributes for #Unity3D
View DisableWhenAttribute.cs
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <>.
/// @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:
using System;
using UnityEngine;
capnslipp / StringIndexOffsetExtensions_Playground.swift
Last active April 20, 2017 02:24
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 / Full-width content.css
Last active December 2, 2016 20:23
Userstyle CSS for*
View Full-width content.css
@-moz-document url-prefix(""), url-prefix("") {
.section-content {
margin-left: 4rem !important;
margin-right: 4rem !important;
width: auto !important;
.topic-description, .topic-content {
width: auto !important;
float: none !important;

Keybase proof

I hereby claim:

  • I am capnslipp on github.
  • I am 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 / SCNViewController.swift
Last active September 18, 2016 01:49
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:
import UIKit
import SceneKit
capnslipp / NilCoalescingAssignmentOperators.swift
Last active February 6, 2017 19:28
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 / GlobalsStruct.swift
Last active July 23, 2016 00:32
Swift struct private init() test
View GlobalsStruct.swift
public struct GlobalsStruct {
public static let aValue = 5
private init() {}
capnslipp / CodeWithDifferingIntentsShouldLookDifferent.swift
Last active September 17, 2022 15:53
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 {
class SuperClass {}
class AType {
capnslipp / NonDrawingGraphic.cs
Last active November 14, 2022 06:53
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 <>.
/// @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:
using UnityEngine;
using UnityEngine.UI;