Skip to content

Instantly share code, notes, and snippets.

// say that the object which is our _delegate is the only object retaining us
// and it calls this -processStuff method…
- (void)processStuff
{
// and then this happens:
[_delegate finishedSomething:self];
// now, in _delegate's -finishedSomething: it ends up releasing us like so:
We need more information to investigate this issue.
If this happens again: please check if turning off/on wifi resolves the issue?
Another thing that can be done is getting mDNSResponder logs:
1. Turn on verbose logging with
a) sudo syslog -c mDNSResponder -i
b) sudo killall -USR1 mDNSResponder
c) sudo killall -USR2 mDNSResponder
d) syslog -w > ~/Desktop/mDNS.log
@BigZaphod
BigZaphod / Pathfinding.swift
Created November 24, 2015 17:33
AStar pathfinding in Swift
// uses PriorityQueue from https://github.com/mauriciosantos/Buckets-Swift
protocol Pathfinding {
typealias Node: Hashable
func neighborsFor(node: Node) -> [Node]
func costFrom(from: Node, to: Node) -> Int
func heuristicFrom(from: Node, to: Node) -> Int
}
class Thing {
var something: Int? = nil
func doSomething() -> Int {
if something == nil {
something = 42
}
return something * 2 // compiler complains because it thinks "something" might somehow not have a value in some case
}
// translates a normalized texture coordinate into a normalized texture coordinate that has been "snapped" to the center of a pixel
vec2 nearest(vec2 uv, vec2 size) {
vec2 pixel = uv * size;
vec2 snapped = floor(pixel - 0.5) + 0.5;
return (snapped + step(0.5, pixel - snapped)) / size;
}
@BigZaphod
BigZaphod / struct.lua
Last active July 6, 2017 01:27
A read only struct value type for Lua
--[[
An immutable structure-like value type for Lua.
Sean Heber (sean@fifthace.com)
BSD License
July, 2017
Written on an iPad using Codea (https://codea.io)
I’m pretty new to Lua, but I kept running into situations where I wanted to use a complex value type
such as a Point as a key in a table. Unfortunately since each table instance is unique, using a table
@BigZaphod
BigZaphod / KeyboardAwareContainerView.h
Last active December 25, 2022 19:07
A simple UIView that will move the contentView out of the way of the keyboard. It animates in sync with the keyboard and always works - even in a modal page sheet, a slide over, or any other context. Tested on iOS 12 and iOS 13.
// Created by Sean Heber on 9/26/19.
@import UIKit;
@interface KeyboardAwareContainerView : UIView
@property (nonatomic, readonly, nonnull) UIView *contentView;
@end
typealias GeometricValue = Numeric & Comparable
struct GenericPoint<ValueType: GeometricValue>: Equatable {
var x: ValueType
var y: ValueType
static var zero: Self { Self(x: 0, y: 0) }
}
extension GenericPoint {
// Created by Sean Heber (@BigZaphod) on 10/12/19.
// License: BSD
import Foundation
//==---------------------------------------------------------
/// This implementation requires the ability to initialize an
/// instance of a type before it can decode it. This is to support
/// reference types automatically so that each instance is
/// only stored once in the archive. Decoding a reference
protocol ReferenceEquatable: AnyObject, Equatable {}
extension ReferenceEquatable {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs === rhs
}
}
protocol ReferenceHashable: ReferenceEquatable, Hashable {}