Skip to content

Instantly share code, notes, and snippets.

Michael Helmbrecht mrh-is

Block or report user

Report or block mrh-is

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ObjCConvertible.swift
import Foundation
protocol ObjCConvertible {}
extension String: ObjCConvertible {}
extension Int: ObjCConvertible {}
extension Double: ObjCConvertible {}
extension Bool: ObjCConvertible {}
func objCMethod(_ dict: [String: AnyObject]) {
print(dict)
@mrh-is
mrh-is / StrongFunctionReference.swift
Created Jan 30, 2018
Function references are strong references in Swift
View StrongFunctionReference.swift
class BlockHolder {
let block: () -> Void
init(block: @escaping () -> Void) {
self.block = block
}
}
class Doer {
func doIt() {
print("done")
@mrh-is
mrh-is / SantaArrivalCalculator.swift
Created Dec 23, 2016
When will Santa be at my house?
View SantaArrivalCalculator.swift
extension Location {
func closestLocationOnPath(start: Location, end: Location) -> (location: Location, t: Double, distance: Double) {
let pathVector = (latitude: end.latitude - start.latitude, longitude: end.longitude - start.longitude)
var t = (self.latitude * pathVector.latitude - start.latitude * pathVector.latitude + self.longitude * pathVector.longitude - start.longitude * pathVector.longitude) / (pow(pathVector.latitude,2) + pow(pathVector.longitude,2))
t = min(max(t, 0), 1)
let closestLocation = Location(latitude: start.latitude + t * pathVector.latitude, longitude: start.longitude + t * pathVector.longitude)
return (location: closestLocation, t: t, distance: distance(to: closestLocation))
}
func distance(to other: Location) -> Double {
@mrh-is
mrh-is / update_xcode_plugins.sh
Created Dec 16, 2014
Update DVTPlugInCompatibilityUUIDs for installed plugins for all Xcode versions
View update_xcode_plugins.sh
#!/bin/sh
# Based on https://gist.github.com/neonichu/9487584
# Now automatically updates every plugin for every version of Xcode on your machine
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
@mrh-is
mrh-is / RLMResultsIterationIssue.swift
Last active Aug 29, 2015
RLMResults iteration issue
View RLMResultsIterationIssue.swift
class MyObject: RLMObject {
dynamic var property: Int = 0
}
// Create some data
let realm = RLMRealm.defaultRealm()
realm.beginWriteTransaction()
for i in 1...6 {
realm.addObject(MyObject())
}
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 17/01/2014
  • Original post

You can’t perform that action at this time.