Skip to content

Instantly share code, notes, and snippets.

@loganwright
loganwright / UIImage+Base64.h
Created February 19, 2015 20:56
UIImage+Base64
#import <UIKit/UIKit.h>
@interface UIImage (Base64)
- (NSString *)base64EncodedVersion;
+ (UIImage *)imageWithBase64String:(NSString *)base64String;
@end
@loganwright
loganwright / osxurl.md
Created February 2, 2015 16:57
osx url responder

Add Listener

[[NSAppleEventManager sharedAppleEventManager] setEventHandler:shared
                                                   andSelector:@selector(handleURLEvent:withReplyEvent:)
                                                 forEventClass:kInternetEventClass
                                                    andEventID:kAEGetURL];

Respond to events

@loganwright
loganwright / Example.md
Created January 27, 2015 18:29
JSONMappableObject

A basic class for mapping JSON objects to their models. Also fully compliant w/ NSCoding automatically. The only thing you need to do is subclass the model, declare your properties, and then override mapping using the following syntax:

- (NSMutableDictionary *)mapping {
  NSMutableDictionary *mapping = [super mapping];
  mapping[@"propertyName"] = @"associatedJSONKey";
}

If your property maps to another JSONMappableObject, or an array of them, use the following syntax for your mapping key:

@loganwright
loganwright / CountBits.md
Last active August 29, 2015 14:13
Programming Puzzles

Count the number of binary 1 flags for a given positive integer. For instance:

1 = 0b1 => 1 bit 2 = 0b10 => 1 bit 3 = 0b11 => 2 bits

Recursively

func countBitsRec(var n: NSInteger) -> NSInteger {
 return n == 0 ? 0 : n &amp; 1 + countBits(n &gt;&gt; 1)
@loganwright
loganwright / MEImageManager.swift
Created January 13, 2015 19:12
MEImageManager.swift
//
// MEApplicationSettings.swift
// MagicEyes
//
// Created by Logan Wright on 12/26/14.
// Copyright (c) 2014 Intrepid Pursuits, LLC. All rights reserved.
//
import UIKit
@loganwright
loganwright / SetupCocoaPods.md
Last active August 28, 2020 16:39
Setting Up Cocoapods Guide

#Cocoapods

##Installing Cocoapods

  • Open Terminal
  • Enter command: sudo gem install cocoapods
  • Enter your password

Wait for this to finish, don't touch your terminal. It might take a couple minutes

@loganwright
loganwright / Contact.swift
Created January 9, 2015 19:03
SwiftContact - Converting ABRecordRef to Clean, usable contact object
//
// Contact.swift
// FriendLender
//
// Created by Logan Wright on 9/22/14.
// Copyright (c) 2014 lowriDevs. All rights reserved.
//
import UIKit
import AddressBook
#import <UIKit/UIKit.h>
@interface LGMarginLabel : UILabel
@property (nonatomic) UIEdgeInsets marginInsets;
@end
@loganwright
loganwright / UIView+NibInitable.h
Created January 7, 2015 15:39
UIView+NibInitable
#import <UIKit/UIKit.h>
@interface UIView (NibInitable)
- (instancetype)initWithNibNamed:(NSString *)nibNameOrNil;
@end
@loganwright
loganwright / LGTelephoneHandler.h
Last active August 29, 2015 14:12
LGTelephoneHandler
#import <Foundation/Foundation.h>
@interface MITTelephoneHandler : NSObject
+ (void)attemptToCallPhoneNumber:(NSString *)phoneNumber;
@end