Skip to content

Instantly share code, notes, and snippets.

View Jon889's full-sized avatar

Jonathan Bailey Jon889

  • Elfin Market
  • UK
View GitHub Profile
@Jon889
Jon889 / Step.swift
Last active December 5, 2019 02:13
UI Test reporting
public typealias Given = Step
public typealias When = Step
public typealias Then = Step
public typealias And = Step
public struct Step {
@discardableResult
public init(_ handler: @autoclosure () -> Void, file: String = #file, line lineNumber: Int = #line) {
step(handler, file: file, line: lineNumber)
@Jon889
Jon889 / RawRepresentableExtensions.swift
Last active April 21, 2016 22:54 — forked from joshavant/RawRepresentableExtensions.swift
RawRepresentable, meet NSCoding
enum Status: Int {
case Good
case Bad
}
// Status.RawValue == Int not NSData, therefore this extension should not be applied to status
extension RawRepresentable where RawValue == NSData, Self: NSCoding {
init?(rawValue: NSData) {
if let instance = NSKeyedUnarchiver.unarchiveObjectWithData(rawValue) as? Self {
self = instance
template <class A> struct Failable
{
bool error;
A value;
wxString errorString;
Failable(wxString errorStr) : error(true), errorString(errorStr) {}
Failable(A val) : error(false), value(val) {}
operator A() const { return value; }
};
@Jon889
Jon889 / Cities Skylines Airports
Created May 21, 2015 20:05
Draggable runways and taxiways
using ICities;
using ColossalFramework;
using ColossalFramework.Globalization;
using ColossalFramework.IO;
using ColossalFramework.UI;
using ColossalFramework.Steamworks;
using UnityEngine;
@Jon889
Jon889 / gist:3da22b65d6cc6aec353f
Created April 13, 2015 22:58
Custom Airports Cities Skylines
namespace SomeRoads
{
public class SomeRoadsLoader : LoadingExtensionBase
{
public override void OnCreated(ILoading loading)
{
InitMod();
}
public override void OnLevelLoaded(LoadMode mode)
#import "Preferences/PSSwitchTableCell.h"
@interface JBPLinkSwitchCell : PSSwitchTableCell
@end
@Jon889
Jon889 / classes.js
Last active December 29, 2015 09:49
Javascript Classes More succinct (read hacky) way of making "Classes" in javascript.
//More succinct (read hacky) way of making "Classes" in javascript.
//Use:
/*
Class({NewClass : Superclass}, [
function methodOne() {
//do something
}
});
then use in the usual javascript way:
@interface UIImageView (highlighted)
@property (nonatomic, strong) NSMutableDictionary *highlightedKV;
@property (nonatomic, strong) NSMutableDictionary *unhighlightedKV;
@end
@implementation UIImageView (highlighted)
-(NSMutableDictionary *)highlightedKV {
id returnValue = objc_getAssociatedObject(self, "highlightedKVKey");
if (!returnValue) {
returnValue = [NSMutableDictionary dictionary];
[self setHighlightedKV:returnValue];