Skip to content

Instantly share code, notes, and snippets.

View regnerjr's full-sized avatar

John Regner regnerjr

View GitHub Profile
// Get the file manager
let fileManager = NSFileManager.defaultManager()
// Get the app's available documents directories
// For other options usable in iOS besides .DocumentsDirectory see:
// http://stackoverflow.com/questions/7268299/path-directory-usable-in-ios
let directoryURLs = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) as [NSURL]
// Cast to [NSURL] because it 'helpfully' gives back [AnyObject]
// iOS should only give you a single documents directory for your app
@joshdholtz
joshdholtz / HarmonicStuff.swift
Created June 15, 2015 00:26
OMG, protocol extensions for Harmonic
var json : Dictionary<String, AnyObject> = ["first_name" : "Josh", "last_name" : "Holtz",
"best_friend" : ["first_name" : "Bandit", "last_name" : "The Cat"],
"friends" : [ ["first_name" : "Red Ranger"], ["first_name" : "Green Ranger"] ],
"birthday" : "1989-03-01"
]
var jsons = [json]
/*
* OLD WAY (before protocol extensions)
*/
@dcramps
dcramps / TintMyStatusBar.swift
Last active August 17, 2017 16:01
Use this class if you're a horrible person that wants to change the colour of an iOS status bar. If the status bar changes in any way, you have to do it again. Have fun.
final class TintMyStatusBar {
static func to(_ colour: UIColor) {
let sbw = UIApplication.shared.value(forKey: "statusBarWindow") as! UIWindow
for statusbar in sbw.subviews {
for bgfg in statusbar.subviews {
for itemView in bgfg.subviews {
let image = itemView.layer.contents as! CGImage
itemView.layer.contents = self.tint(image: image, toColour: colour)
}
@marcdown
marcdown / BKLNSwiftPresenters.md
Last active November 5, 2017 03:08
Brooklyn Swift Developers Meetup Presenters
@keith
keith / simctl-commands.txt
Last active December 7, 2022 23:27
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 776.1 (Xcode 13.0 beta 5)
addmedia
addphoto
addvideo
appinfo
boot
bootstatus
clone
create
darwinup
delete
@Ashton-W
Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@joshavant
joshavant / UIView+Utility.swift
Created November 17, 2018 07:40
Ambiguity Treadmill
extension UIView {
@objc func exerciseAmbiguityInLayoutRepeatedly() {
if self.hasAmbiguousLayout {
Timer.scheduledTimer(timeInterval: 0.5,
target: self,
selector: #selector(UIView.exerciseAmbiguityInLayout),
userInfo: nil,
repeats: true)
}
}
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active May 17, 2024 05:49
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S