Skip to content

Instantly share code, notes, and snippets.

View dnedrow's full-sized avatar

David Nedrow dnedrow

View GitHub Profile
//
// UIImage+Extensions.swift
//
// Created by Daniel Tartaglia on 4/25/16.
// Copyright © Daniel Tartaglia. MIT License.
//
import UIKit
@dnedrow
dnedrow / Signal.swift
Created September 22, 2018 12:35 — forked from danielt1263/Signal.swift
Swift replacement for KVO
//
// Signal.swift
//
// Created by Daniel Tartaglia on 9/6/15.
// Copyright © 2016 Daniel Tartaglia. MIT License.
//
public protocol Disposable {
func dispose()
}
@dnedrow
dnedrow / version_comparator.sh
Last active November 18, 2020 12:21
bash function for comparing version numbers
#!/usr/bin/env bash
function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" > "$1"; }
function version_eq() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" = "$1"; }
function version_lt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" < "$1"; }
RUBY_VERSION=$(/usr/bin/ruby -v | awk '{print $2}' | cut -d'p' -f1)
echo "ruby version is ${RUBY_VERSION}"
@dnedrow
dnedrow / doOnce.swift
Created May 15, 2018 14:48 — forked from samsonjs/doOnce.swift
A function that only executes once. Good Swift or over-clever?
// Swift3 gets rid of dispatch_once and recommends replacing it with a lazy global.
// That's very straightforward when dispach_once is used to initialize something, but
// isn't an exact match when you want something to execute once, and then become a noop
// in a thread-safe way.
// The following approach seems completely "correct" and I guess actually a bit elegant,
// if by "elegant" you mean "terse and not immediately obvious to the reader, which makes
// you look very clever."
var doOnce: () -> Void = {
@dnedrow
dnedrow / doOnce.swift
Created May 15, 2018 14:46 — forked from rnapier/doOnce.swift
A function that only executes once. Good Swift or over-clever?
// Swift3 gets rid of dispatch_once and recommends replacing it with a lazy global.
// That's very straightforward when dispach_once is used to initialize something, but
// isn't an exact match when you want something to execute once, and then become a noop
// in a thread-safe way.
// The following approach seems completely "correct" and I guess actually a bit elegant,
// if by "elegant" you mean "terse and not immediately obvious to the reader, which makes
// you look very clever."
var doOnce: () -> Void = {