Skip to content

Instantly share code, notes, and snippets.

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
// 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:
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
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 {
protocol ReferenceEquatable: AnyObject, Equatable {}
extension ReferenceEquatable {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs === rhs
}
}
protocol ReferenceHashable: ReferenceEquatable, Hashable {}
extension BinaryInteger {
subscript(bit index: Int) -> Bool {
get {
((self >> index) & Self(1)) == 1
}
set {
if newValue {
self |= (Self(1) << index)
} else {
self &= ~(Self(1) << index)

I recently started a private Minecraft server on my Linode. I was dismayed to discover that it caused the CPU graph on the Dashboard to spike to 100% despite the CPU usage as reported by top being only around 40-50% when a couple of players were present and around 10% when idle. I spent a lot of time worrying about this and even opened a support ticket to make sure I wasn't doing anything terribly wrong. Support pointed me to a post that discussed the same issue. The conclusion appears to be that it's a bug either in Minecraft or Java and it is confusing the reporting but isn't a real problem.

Despite this, I decided I didn't really like seeing the CPU graph maxed out all of the time, nor did I like the idea that Minecraft sits there consuming 10% of the CPU even when idle. While looking for solutions I ran across a b

@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
}