Skip to content

Instantly share code, notes, and snippets.

View mmertsock's full-sized avatar
💭
⛰️ 🐐

Mike Mertsock mmertsock

💭
⛰️ 🐐
View GitHub Profile
// A reusable class that satisfies isGenericMatcher:
@interface SOHaveCountOfGenericMatcher : NSObject
- (id)initWithCount:(NSUInteger)count;
- (BOOL)matches:(id)item; // this is what KWMessagePattern looks for
@property (readonly, nonatomic) NSUInteger count;
@end
@implementation SOHaveCountOfGenericMatcher
- (id)initWithCount:(NSUInteger)count
{
@mmertsock
mmertsock / gist:5509128
Created May 3, 2013 13:33
BeforeEachExample/AfterEachExample/Afterward mockup for https://github.com/trackabout/speceasy/pulls/1
public class MySpec : Spec<SomeClass>
{
protected override void BeforeEachExample()
{
}
protected override void AfterEachExample()
{
}
@interface TestClass1 : NSObject
+ (NSString *)getSomeString;
- (NSString *)doSomething;
- (NSString *)doSomethingElse;
@end
@interface TestClass1 (TestClass1Catgegory)
+ (NSString *)ext_getSomeString:(NSString *)input;
@end
@mmertsock
mmertsock / gist:5834047
Created June 21, 2013 20:22
FallbackRegistrationProvider for TinyIoC
internal interface IFallbackRegistrationProvider
{
bool TryRegister(Type registerType, TinyIoCContainer container);
}
internal sealed class TinyIoCContainer : IDisposable
{
public IFallbackRegistrationProvider FallbackRegistrationProvider { get; set; }
private class NullFallbackRegistrationProvider : IFallbackRegistrationProvider
{
@mmertsock
mmertsock / gist:5935405
Created July 5, 2013 15:45
Object Oriented validation rules
// the entity you want to validate
public class Person
{
public int Age { get; set; }
public string Name { get; set; }
}
public class ValidationFailure
{
public ValidationFailure(string description) { Description = description; }
@mmertsock
mmertsock / MMViewController.h
Last active December 20, 2015 00:49
Simple UIColor testing tool. Create a new Single View Application in Xcode, with Storyboard and ARC enabled. Paste the code below into the .h and .m files for your view controller, and then right click your storyboard file, and choose Open As > Source Code. Then paste the XML below for the code of the storyboard. This should create a view with t…
#import <UIKit/UIKit.h>
@interface MMViewController : UIViewController
@property (nonatomic, weak) IBOutlet UIView *colorView;
@property (nonatomic, weak) IBOutlet UILabel *hLabel;
@property (nonatomic, weak) IBOutlet UILabel *sLabel;
@property (nonatomic, weak) IBOutlet UILabel *bLabel;
@mmertsock
mmertsock / gist:6062763
Created July 23, 2013 14:26
An example of bogus JSON
{ "sample": this is bogus }
@mmertsock
mmertsock / publish_pod.sh
Last active July 16, 2018 08:57
Helper script template for publishing podspecs to a private repository. Place the `publish_pod.sh` file in the root directory of your pod (the same directory as your podspec file). You should also have a working copy of your private Cocoapods pod repository. The path of the pods repo and the name of the pod need to be inserted into the script te…
set -e # http://stackoverflow.com/q/2870992/795339
podname=<TODO:NAME>
version=$(grep s.version $podname.podspec | head -1 | cut -d = -f 2 | cut -d '"' -f 2)
poddir=<TODO:ROOT DIRECTORY OF YOUR LOCAL PODS REPO>/$podname/$version
# This should print without any quote characters. Otherwise the script will break.
echo "Publishing $podname release $version..."
echo "The podspec file should be updated with a new version number. Going to commit."
@mmertsock
mmertsock / Hello.cs
Created September 29, 2014 20:55
Add ServiceStack Reference codegen issues
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ServiceStack;
namespace AddSsRefHost.ServiceModel
{
[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
import XCTest
func NSCalendarForTesting() -> NSCalendar {
let calendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)!
calendar.timeZone = NSTimeZone(name: "America/New_York")!
calendar.firstWeekday = 2 // Monday
return calendar
}
class NSCalendarTests: XCTestCase {