Skip to content

Instantly share code, notes, and snippets.

View mteece's full-sized avatar

Matthew Teece mteece

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mteece on github.
  • I am mteece (https://keybase.io/mteece) on keybase.
  • I have a public key whose fingerprint is A11C 93B2 294C B115 A311 4302 6BB8 8693 3E75 10B6

To claim this, I am signing this object:

@mteece
mteece / ExampleClass-new.h
Created July 28, 2014 19:38
The past way and the the new and improved way of writing Objective-C classes, and properties with the modern Objective-C compiler.
@interface ExampleClass : UIViewController
@property (nonatomic, assign) BOOL someBool;
// a few method declarations
@end
@mteece
mteece / basic-auth-afnetworking-2-0.m
Created July 28, 2014 18:25
Post JSON Body to API with Basic HTTP Authentication using Objective-C and AFNetworking 2.0
NSString *URLString = @"http://example.com/path";
NSDictionary *parameters = @{ };
NSURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
@mteece
mteece / compareversions.js
Created May 23, 2014 19:28
Compare the installed to required version. Assumes Semantic Versioning.
/*
* Compare the installed to required version.
*
* @param {String} installed The currently installed version string.
* @param {String} required The required version string.
*
* compareVersions('1.0.1', '1.0.0') returns true
* compareVersions('1.0.0', '1.0.0') returns true
* compareVersions('0.0.9', '1.0.0') returns false
* compareVersions('1.0.0', '1.0.1') returns false
@mteece
mteece / bennett.cs
Created November 26, 2013 15:32
Let off some steam, Bennett.
static void Main()
{
Console.WriteLine(@"
LET OFF SOME STEAM, BENNETT.
'''';;;;;;;;;;;';;;''';::,,,:::::::;''++++++++++++
;;;::::;;;;;;;;'++#'';;::,,,:::;;::;''++++++++++++
;;::::::::;;;;##++#@#';;:,,:::;;;;;;''++++++++++++
;;::::::::;;;#+,,,,;;+;;:::::;;'';;;'''+++++++++++
@mteece
mteece / EmailRepository.h
Created October 18, 2013 14:57
Objective-C blocks and Grand Central Dispatch. Using GCD and blocks effectively.
#import <Foundation/Foundation.h>
@interface EmailRepository : NSObject
+ (id)sharedEmailRepository;
- (void)getDataFromServer:(NSString *)emailAddress onComplete:(void (^)(NSString *response))completionBlock onFailure:(void (^)(NSString *response))failureBlock;
@end
@mteece
mteece / .gitignore
Created September 4, 2013 01:25
Ignore rules for IOS/XCode/Obj-c.
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@mteece
mteece / RPS.js
Last active December 21, 2015 21:19 — forked from joehinkle/RPS.js
Making game and objects configurable for rock, paper, scissors, lizard, spock. See http://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spock.
// Initializing Variables
var userChoice = prompt("Do you choose rock, paper, scissors, lizard, or spock?");
var choices = ["rock", "paper", "scissors", "lizard", "spock"];
var computerChoice = choices[ Math.floor( Math.random() * choices.length ) ];
// Function that compares the two values
function compare( choice1, choice2 ) {
var rock = {
defeats: ["scissors", "lizard"],
@mteece
mteece / nsdictionarytojson.m
Created July 16, 2013 13:52
Generate JSON from an NSDictionary.
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryOrArrayToOutput options:NSJSONWritingPrettyPrinted error:&error];
if (!jsonData) {
NSLog(@"Got an error: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
@mteece
mteece / requestwithafnetworking.m
Created March 31, 2013 21:58
AFNetworking and NSMutableURLRequest generate a request with params.
/*
Generate a request with params.
POST /post/url
Host: www.example.com
Content-Type: application/x-www-form-urlencoded; charset=utf-8
uuid=12345-ABC-9876-XYZ&first_name=john&last_name=doe
*/