Skip to content

Instantly share code, notes, and snippets.

View andrewgrant's full-sized avatar

Andrew Grant andrewgrant

View GitHub Profile
@andrewgrant
andrewgrant / EmojiStateIcon
Last active August 29, 2015 14:22
Example of filling in a tableview cell with Emoji used to represent the completed state
// ReminderTableViewCell is a custom cell with a left-aligned button used to toggle the completed state of an EventKit reminder
let reminderCell = tableView.dequeueReusableCellWithIdentifier("ReminderCell") as! ReminderTableViewCell
let reminder = self.reminders[indexPath.row]
reminderCell.titleLabel.text = reminder.title
reminderCell.completeButton.setTitle(reminder.completed ? "🔳" : "◻️", forState: UIControlState.Normal)
reminderCell.completeButton.tag = indexPath.row
@andrewgrant
andrewgrant / CGColorEncoding
Created June 30, 2015 03:42
Encoding a CGColor in Swift via converting an UnsafePointer to an array
required init(coder aDecoder: NSCoder) {
let colorArray = aDecoder.decodeObjectForKey("colors") as! [CGFloat]
self.CGColor = CGColorCreate(CGColorSpaceCreateDeviceRGB(), colorArray)
super.init()
}
func encodeWithCoder(aCoder: NSCoder) {
@andrewgrant
andrewgrant / UEBuildModule.cs
Created September 16, 2016 15:06
Modified UBT so that checked out/writable files excluded by adaptive unity have optimization turned off for ease of debugging. Prior to UE 4.14 this also requires a modification to VCToolChain due to assumptions about optimization settings.
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
@andrewgrant
andrewgrant / BuildCookTest.cs
Created October 20, 2017 17:15
Example of creating a UAT script for Unreal that leverages the BuildCookRun command. The Test/Run part is omitted because it's in a private project, but the "Run" part of BuildCookRun could be used instead
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AutomationTool;
using UnrealBuildTool;
using Gauntlet;
using System.Net.NetworkInformation;
using static AutomationTool.P4Connection;
@andrewgrant
andrewgrant / gist:f842d87f48c4d54256e8d37c6d0d9f95
Created August 19, 2019 19:58
Fastlane script that pulls all devices from one or more apple accounts, dedupes them, and writes them to a csv
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
require 'spaceship'
default_platform(:ios)
platform :ios do
desc "Pulls a list of all devices from our accounts and dedupes them "
lane :dump_devices do
@andrewgrant
andrewgrant / InstallBuild.cs
Created September 13, 2019 19:19
Example of using Gauntlet in Unreal to deploy builds to devices
using AutomationTool;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnrealBuildTool;
namespace Gauntlet.Examples
@andrewgrant
andrewgrant / gist:477c7037b1fc0dd7275109d3f2254ea9
Created July 6, 2020 19:44
Example changes for automake to support x86 & arm64 plus universal binaries
# configure.ac
# add an --enable-macos-universal-binary flag that when building for mac
# create a universal x86_64 / arm64 binary
AC_ARG_ENABLE([macos-universal-binary],
[AS_HELP_STRING([--enable-macos-universal-binary],
[Create an universal x86_64+arm64 binary when building for macos)])],,
[enable_macos_universal_binary=no])
# Determine if we're building for macos/darwin by checking for macos & darwin
@andrewgrant
andrewgrant / gist:e5826ebb2924ea37c7802aa93e3d637f
Created July 9, 2020 14:06
Bash expansions to extract file components and extension from paths
From
https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
~% FILE="example.tar.gz"
~% echo "${FILE%%.*}"
example
~% echo "${FILE%.*}"