Skip to content

Instantly share code, notes, and snippets.

Oliver Atkinson ollieatkinson

  • Sky
  • United Kingdom
Block or report user

Report or block ollieatkinson

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
ollieatkinson / XCTAssertColor.swift
Last active Jul 24, 2019
Assert that two colors are similar using XCTest
View XCTAssertColor.swift
func XCTAssertColor(_ l: UIColor?, _ r: UIColor, accuracy: CGFloat, file: StaticString = #file, line: UInt = #line) {
guard let l = l else {
XCTFail("Color is 'nil'", file: file, line: line)
var (lh, rh) = (CGFloat(0), CGFloat(0))
var (lb, rb) = (CGFloat(0), CGFloat(0))
var (ls, rs) = (CGFloat(0), CGFloat(0))
ollieatkinson / Predicate.swift
Last active Jun 30, 2019
A definition of logical conditions used to constrain a search for in-memory filtering
View Predicate.swift
public func == <Root, Value: Equatable>(keyPath: KeyPath<Root, Value>, value: Value) -> (Root) -> Bool {
return { $0[keyPath: keyPath] == value }
public func != <Root, Value: Equatable>(keyPath: KeyPath<Root, Value>, value: Value) -> (Root) -> Bool {
return { $0[keyPath: keyPath] != value }
public func < <Root, Value: Comparable>(keyPath: KeyPath<Root, Value>, value: Value) -> (Root) -> Bool {
return { $0[keyPath: keyPath] < value }
ollieatkinson /
Last active Jul 6, 2018
Generate public API for a swift module using sourcekitten
cd $(dirname "$0")
# Extract the toolchain identifier
export TOOLCHAIN_IDENTIFIER=$(/usr/libexec/PlistBuddy -c "Print :Identifier" "$(printenv TOOLCHAIN_DIR)/ToolchainInfo.plist")
# Replace the {{KEY}} with the values from the environment variables
cat request_template.yml | perl -pe 's/\{\{(\w+)\}\}/$ENV{$1}/eg' > $PROJECT_DIR/request.yml
ollieatkinson /
Last active Dec 21, 2017
2017 Sky Christmas Competition - find `n` which produces the sum of divisors over `x` [Rust] - Sum of Divisors, Prime Factorisation, Highly Abundant Numbers
use std::time::Instant;
fn main() {
let start = Instant::now();
let input = env!("PRESENTS");
let (index, _sum) = find_sum_of_divisors_over(input.parse::<u32>().unwrap() / 10);
println!("{}", index);
ollieatkinson / GradientView.swift
Last active Jun 19, 2017
A Simple UIView Wrapper for CAGradientLayer
View GradientView.swift
/// A Simple UIView Wrapper for CAGradientLayer. It is a plain UIView whose layer
/// is a CAGradientLayer. It is useful if using a view is more convenient than using a layer, e.g.
/// because you want to use autoresizing masks.
class GradientView: UIView {
/// The direction to draw the gradient, in a single point coordinate space.
enum Direction {
/// Draw the gradient from top to bottom.
case vertical
View TestViewControllerTransitionCoordinator.swift
func makeTestViewControllerTransitionCoordinator() -> UIViewControllerTransitionCoordinator {
class ViewControllerTransitionCoordinator: NSObject, UIViewControllerTransitionCoordinatorContext, UIViewControllerTransitionCoordinator {
public var isAnimated: Bool { return false }
public var presentationStyle: UIModalPresentationStyle { return .formSheet }
public var initiallyInteractive: Bool { return false }
ollieatkinson / Waterfall.swift
Created Mar 22, 2017
WIP: Waterfall 'esc' Promises
View Waterfall.swift
//: Playground - noun: a place where people can play
import Foundation
import PlaygroundSupport
class Waterfall<T> {
typealias Execute = (@escaping (Result<T>) -> Void) throws -> Void
typealias Callback = (Result<T>) -> Void
ollieatkinson / AnyDiffable.swift
Last active Apr 18, 2020
Implementation of Paul Heckel's Diff Algorithm in Swift 3
View AnyDiffable.swift
public protocol Diffable: Hashable {
var primaryKeyValue: String { get }
/// A type-erased diffable value.
/// The AnyDiffable type forwards diffing, equality comparisons and hashing operations to an underlying diffing value,
/// hiding its specific underlying type.
ollieatkinson / String+HTML.swift
Last active Mar 3, 2017
Unescape HTML entities in Swift 3 == &#163; -> £
View String+HTML.swift
extension String {
func unescapeHTMLEntities() throws -> String {
guard contains("&#") else {
return self
guard let data = data(using: .utf8) else {
return self
ollieatkinson / URLRequest+cURLCommand.swift
Last active Mar 11, 2017
Generate cURL command's from URLRequest's
View URLRequest+cURLCommand.swift
//: Playground - noun: a place where people can play
import Foundation
extension URLRequest {
/// The cURL representation of the URLRequest, useful for debugging and executing requests outside of the app.
var cURLCommand: String {
var command = "curl"
You can’t perform that action at this time.