Skip to content

Instantly share code, notes, and snippets.

@SeanMcTex
SeanMcTex / FilteredTextField.md
Created May 8, 2020
A pitfall to avoid when filtering SwiftUI TextFields
View FilteredTextField.md

Today’s very hard-won lesson: be careful how you do TextField content filtering! We were filtering input to a text field (making sure the field only accepted numbers, etc.) like so:

@Binding var value: String
TextField( placeholder, text: $value )
    .onReceive( Just( value ), perform: { 
		self.value = self.contentType.filterCharacters( oldValue: $0 ) 
	})
@SeanMcTex
SeanMcTex / README-Template.md
Created Mar 7, 2019 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@SeanMcTex
SeanMcTex / MeshMeasure.cs
Created Jan 24, 2019
Unity Utility to display bounds of mesh objects in world space
View MeshMeasure.cs
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
/// <summary>
/// In order to help gauge the size of mesh objects,
/// this script displays the dimensions in world space of a selected object
/// with a MeshRenderer attached whenever it's selected.
/// </summary>
@SeanMcTex
SeanMcTex / PinToSafeArea.cs
Last active May 17, 2021
Restrict Unity UI to an iPhone X or other Mobile Device's Safe Area
View PinToSafeArea.cs
using UnityEngine;
/// <summary>
/// Resizes a UI element with a RectTransform to respect the safe areas of the current device.
/// This is particularly useful on an iPhone X, where we have to avoid the notch and the screen
/// corners.
///
/// The easiest way to use it is to create a root Canvas object, attach this script to a game object called "SafeAreaContainer"
/// that is the child of the root canvas, and then layout the UI elements within the SafeAreaContainer, which
/// will adjust size appropriately for the current device./// </summary>
View gist:c3c7c96c406facdf96a4

WWDC 2015 Wish List & Predictions, the Developer's Perspective

Mutual Mobile has been very lucky this year to have a number of our devs awarded tickets to attend WWDC. As the time grows close, speculation about what we'll be seeing this year is reaching a fever pitch. As developers, we have a lot of stake in what Apple reveals in a couple of short weeks, and we've had some great discussions about what we expect to see and what we are hoping for. Here are a number of the things we're wishing for and estimates of how likely we think it is that our dreams will come true.

New Apple TV

The last time Apple mentioned the Apple TV, they lowered the price: "starting at $69". The "starting at" makes it a near certainty that there's an updated Apple TV in the works, and rumors seem to indicate that an SDK for doing development for the updated box is a very likely as well. An SDK would allow video providers to create new apps to share video content from a variety of new sources, and to enrich that video content w

View gist:0a287bf6ffeb84068b75
# WWDC 2015 Wish List & Predictions, the Developer's Perspective
Mutual Mobile has been very lucky this year to have a number of our devs awarded tickets to attend WWDC. As the time grows close, speculation about what we'll be seeing this year is reaching a fever pitch. As developers, we have a lot of stake in what Apple reveals in a couple of short weeks, and we've had some great discussions about what we expect to see and what we are hoping for. Here are a number of the things we're wishing for and estimates of how likely we think it is that our dreams will come true.
## New Apple TV
The last time Apple mentioned the Apple TV, they lowered the price: "starting at $69". The "starting at" makes it a near certainty that there's an updated Apple TV in the works, and rumors seem to indicate that an SDK for doing development for the updated box is a very likely as well. An SDK would allow video providers to create new apps to share video content from a variety of new sources, and to enrich that video content w
@SeanMcTex
SeanMcTex / swift-cheat-sheet.md
Created Jun 4, 2014
Quick Reference for the Most Commonly Needed Accessibility Functionality in Swift for iOS
View swift-cheat-sheet.md

Accessibility Cheat Sheet for Swift

The Basics

fireButton.accessibilityLabel = NSLocalizedString( "Fire Weapons", comment: "Fire weapons button label" )
fireButton.isAccessibilityElement = true
fireButton.accessibilityHint = "Clearly, you should push this button to shoot your weapons at the bad guys"

Notifications

UIAccessibilityPostNotification( UIAccessibilityScreenChangedNotification, self.fireButton )
UIAccessibilityPostNotification( UIAccessibilityLayoutChangedNotification, nil )
We couldn’t find that file to show.
@SeanMcTex
SeanMcTex / gist:6318927
Last active Dec 21, 2015
Unit Tests That Write Themselves: Part Two
View gist:6318927

Unit Tests That Write Themselves: Part Two

In the first article in this series, we set up an abstract parent class for our view controller tests and used Objective C's runtime library to create dynamically named tests for all of its concrete subclasses. This technique can save a lot of time, but we still have to remember to create a new test case for each view controller class.

Is it possible to make unit tests even more automatic? By gazing deep into the occult mysteries of the runtime system, we will answer this question and, if we're lucky, discover a little bit about love along the way. (Editor's Note: We will not actually discover anything about love.)

If you'd like to follow along with some functional code, you can download the sample project from GitHub.

The Case for Automated Test Creation

@SeanMcTex
SeanMcTex / gist:6308966
Last active Dec 21, 2015
Unit Tests That Write Themselves: Part One
View gist:6308966

Unit Tests That Write Themselves: Part One

Unit tests are fantastic. They make code more robust, refactoring less scary, help developers design programs well, and allow machines do more of the monkey work involved in creating a robust app.

But let's face it: unit tests aren’t always the most fun to write. Worse yet, if developers are trying to achieve high code coverage or adhere to Test Driven Development, they will often end up with a lot of repetitive tests.

This is a state of affairs that wouldn't stand for a minute in application code, but which often passes without a second thought in test code. But if we're serious about testing, this should bother us. We should strive to keep our tests as [^1]DRY as we keep our app.

How do we achieve this? In this article, we'll implement a superclass for test suites with common elements, and see how to use the Objective-C runtime to make sure those tests are named meaningfully. (Teaser: in the followup article, we'll see a technique that delves deeper into r