Skip to content

Instantly share code, notes, and snippets.

View robnadin's full-sized avatar

Rob Nadin robnadin

  • Dyson
  • Bristol, UK
  • 21:50 (UTC +01:00)
  • X @robnadin
View GitHub Profile
@robnadin
robnadin / CustomFontMetrics.swift
Created August 9, 2017 09:15 — forked from zwaldowski/CustomFontMetrics.swift
[WIP] UIFontMetrics Backport from iOS 11
//
// CustomFontMetrics.swift
//
// Created by Zachary Waldowski on 6/6/17.
// Licensed under MIT.
//
import UIKit
private extension UITraitCollection {
protocol LayoutAnchorEdgesContainer {
var topAnchor: NSLayoutYAxisAnchor { get }
var leadingAnchor: NSLayoutXAxisAnchor { get }
var bottomAnchor: NSLayoutYAxisAnchor { get }
var trailingAnchor: NSLayoutXAxisAnchor { get }
func pinAllEdges(to view: LayoutAnchorEdgesContainer)
}
//
// Optional+Unwrapped.swift
//
public enum UnwrapError: Error {
case failedToUnwrap(file: StaticString, function: StaticString, line: UInt)
}
extension Optional {
extension UITextField {
func textRange(from range: NSRange) -> UITextRange? {
guard
let startPosition = position(from: beginningOfDocument, offset: range.location),
let endPosition = position(from: startPosition, offset: range.length) else {
return nil
}
return textField.textRange(from: startPosition, to: endPosition)
}
extension UIViewAnimatingState: CustomStringConvertible {
public var description: String {
switch self {
case .inactive: return "inactive"
case .active: return "active"
case .stopped: return "stopped"
}
}
}
@robnadin
robnadin / ReadMe.txt
Created June 26, 2018 21:39 — forked from WinSe7en/ReadMe.txt
Mac Symantec Uninstall
********* RemoveSymantecMacFiles.command 7.0.49 *********
WARNING: This script will remove all files and folders created by Symantec
Mac OS X products (LiveUpdate Administration Utility files) and
any files within those folders. Therefore, you will lose ALL files
that reside in those folders, including any that you have created.
Usage: RemoveSymantecMacFiles.command [-CcdeFfghIikLlmpQqRrV] [-QQ] [-re] [volume ...]
Summary: If no option or volume is specified, then all Symantec files are
@robnadin
robnadin / Example.swift
Last active February 11, 2020 07:02 — forked from beccadax/Example.swift
Elegant handling of localizable strings in Swift 5.
let color = "blue"
let num = 42
localized("Colorless green ideas sleep furiously.")
localized("Colorless \(color) ideas sleep furiously.")
localized("\(num.formatted("%05d")) colorless green ideas sleep furiously.")
extension FixedWidthInteger {
public init<C: Collection>(littleEndianBytes bytes: C) where C.Element == UInt8 {
let (quotient, remainder) = Self.bitWidth.quotientAndRemainder(dividingBy: 8)
precondition(bytes.count == (quotient + remainder.signum())
var iterator = bytes.makeIterator()
self.init(littleEndianBytes: &iterator)
}
public init<I: IteratorProtocol>(littleEndianBytes iterator: inout I) where I.Element == UInt8 {
@robnadin
robnadin / MuteSoundFile.lua
Last active December 17, 2020 18:44
Mute annoying zone music in World of Warcraft Retail
MuteSoundFileDB = {
["profileKeys"] = {
-- Character-server profiles go here
},
["profiles"] = {
["Zone Music"] = {
["soundList"] = {
["MUS_52_StormwindKeep_INTRO (sound/music/pandaria/mus_51_alliancebattlemarch_hero_01.mp3)"] = 772728,
["MUS_52_Zone_StormwindKeep (sound/music/pandaria/mus_51_alliancebattlemarch_01.mp3)"] = 772726,
["MUS_52_Zone_StormwindKeep (sound/music/pandaria/mus_51_alliancebattlemarch_02.mp3)"] = 772727,
@robnadin
robnadin / MyMedia.sh.txt
Created July 12, 2021 09:45
macOS script for SharedMedia_MyMedia addon
#!/bin/sh
echo "This script will now prepare the files for using SharedMedia_MyMedia"
if [ ! -d ../SharedMedia_MyMedia ]; then
echo "Creating the folders..."
mkdir ../SharedMedia_MyMedia
mkdir ../SharedMedia_MyMedia/background
mkdir ../SharedMedia_MyMedia/border
mkdir ../SharedMedia_MyMedia/font