Skip to content

Instantly share code, notes, and snippets.

View mteece's full-sized avatar

Matthew Teece mteece

View GitHub Profile
@mteece
mteece / find_match.swift
Last active March 9, 2021 20:15
Design a function that takes two string parameters. The function should return the longest substring that fully matches the provided pattern. Assume that the input and pattern characters are alphabetic.
import UIKit
import Foundation
/** Design a function that takes two string parameters:
input
pattern
The function should return the longest substring that fully matches
the provided pattern. Assume that the input and pattern characters are
alphabetic.
@mteece
mteece / uiviewcontroller-sequences.m
Created August 22, 2016 18:37
UIViewController sequences
the proper sequence is
-(void)initWithCoder
-(void)awakefromNib //(if story board is used)
or
-(void)loadView----() //if manually generating the view contoller
-(void)viewDidLoad-----(called only once in the life cycle of viewController)
-(void)viewWillAppear
-(void)viewDidAppear
@mteece
mteece / AppDelegate.m
Created June 8, 2016 20:06
Passing RLMResults into a RLMArray for use in swapping objects. To avoid using sort index properties and rely on the array indices.
#import "AppDelegate.h"
#import <Realm/Realm.h>
// Define your models
@interface Dog : RLMObject
@property NSString *name;
@property NSInteger age;
@end
@implementation Dog
@mteece
mteece / timezone.md
Last active July 29, 2022 22:12
List of NSTimeZone Abbreviations and Names (iOS 9.3.1)

NSTimeZone - Timezone Abbreviations ADT = "America/Halifax"; AKDT = "America/Juneau"; AKST = "America/Juneau"; ART = "America/Argentina/Buenos_Aires"; AST = "America/Halifax"; BDT = "Asia/Dhaka"; BRST = "America/Sao_Paulo"; BRT = "America/Sao_Paulo"; BST = "Europe/London";

@mteece
mteece / exampleTableView.m
Created February 10, 2016 16:37
Fix for heightForHeaderInSection as it is called before viewForHeaderInSection and the view size until I create it.
- (CGSize)tableView:(UITableView *)tableView sizeForHeaderLabelInSection:(NSInteger)section
{
NSString *text = [self tableView:tableView titleForHeaderInSection:section];
CGSize constraint = CGSizeMake(self.view.frame.size.width - kSectionTitleLeftMargin - kSectionTitleRightMargin, kMaxSectionTitleHeight);
return [text sizeWithFont:[self fontForSectionHeader] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
@mteece
mteece / data.json
Created August 31, 2015 19:07
Deserialize JSON to Objective-C
{
"completed_in": 0.012,
"max_id": 136536013832069120,
"max_id_str": "136536013832069120",
"next_page": "?page=2&max_id=136536013832069120&q=twitterapi&rpp=1",
"page": 1,
"query": "twitterapi",
"refresh_url": "?since_id=136536013832069120&q=twitterapi",
"results": [
{
@mteece
mteece / .gitignore
Created June 10, 2015 14:43
Merged Liftoff and Objective-C.gitignore
# OS X Finder
.DS_Store
# Xcode per-user config
*.pbxuser
!default.pbxuser
*.mode1
*.mode1v3
!default.mode1v3
*.mode2v3
  • To add Settings.bundle in Xcode. Command N and in Resource, choose Settings Bundle .
  • Open Root.plist in source code, paste the code below to replace it,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PreferenceSpecifiers</key>
	
@mteece
mteece / gist:d16b1298b677d0f75e44
Created November 7, 2014 17:03
Adding kdiff3 two Windows Git as mergetool.

Either add this to your gitconfig:

[merge]
    tool = kdiff3
[mergetool "kdiff3"]
    cmd = \"C:\\\\Program Files\\\\KDiff3\\\\kdiff3\" $BASE $LOCAL $REMOTE -o $MERGED

Or run These at the command line:

$ git config --global merge.tool kdiff3

@mteece
mteece / moveto.js
Last active August 29, 2015 14:07
Move an item in array to a position.
moveTo = function (arr, value, position) {
var index = arr.indexOf(value), newPos = position - 1, temp = arr[newPos];
if (index === -1) return;
if (newPos >= arr.length || newPos < 0) return;
if (index === newPos) return;
arr.splice(newPos, 1, value); // Remove 1 item at newPos insert value
arr.splice(index, 1, temp); // Remove 1 item at index, insert temp
}
//var a = ['Matt', 'Ralph', 'Jason'];