Skip to content

Instantly share code, notes, and snippets.

@Jerrot
Jerrot / XcodePreviews_UIKit.swift
Last active April 6, 2020 13:08
Use Xcode 11 UI Preview feature for UIKit Views
import SwiftUI
final class SomeView: UIView {
init() {
super.init(frame: CGRect.zero)
// TODO: create your view content
}
@available(*, unavailable)
required init?(coder: NSCoder) {
@Jerrot
Jerrot / URLSession Calls in Swift 4
Created January 9, 2019 09:40 — forked from cmoulton/URLSession Calls in Swift 4
URLSession Calls in Swift 4
func makeGetCall() {
// Set up the URL request
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1"
guard let url = URL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = URLRequest(url: url)
// set up the session
@Jerrot
Jerrot / .gitconfig
Last active June 28, 2017 09:38
Temporary ignore/unignore git files when using the index (like git add -A)
[alias]
ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged
ignored = !git ls-files -v | grep "^[[:lower:]]"

Rules

Attributes

Identifier Enabled by default Supports autocorrection
attributes Disabled No

Attributes should be on their own lines in functions and types, but on the same line as variables and imports.

@Jerrot
Jerrot / clean_xcode.sh
Created October 23, 2015 10:08
Resets all installed Xcode simulators and deletes the contents of Derived Data
#!/bin/sh
instruments -s devices \
| grep "(\d[.0-9]\+) \[[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}\]" \
| grep -o "[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}" \
| while read -r line ; do
echo "Reseting Simulator with UDID: $line"
xcrun simctl erase $line
done
@Jerrot
Jerrot / ArrayTransform.swift
Last active March 17, 2024 13:10
Transform arrays with ObjectMapper to Realm's List type
// Based on Swift 1.2, ObjectMapper 0.15, RealmSwift 0.94.1
// Author: Timo Wälisch <timo@waelisch.de>
import UIKit
import RealmSwift
import ObjectMapper
import SwiftyJSON
class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType {
typealias Object = List<T>