Skip to content

Instantly share code, notes, and snippets.

@loganwright
loganwright / LGWatchKitListener.swift
Last active August 29, 2015 14:10
"Real Time" Data - WatchKit
//
// LGWatchKitListener.swift
// RemoteCamera
//
// Created by Logan Wright on 11/19/14.
// Copyright (c) 2014 lowriDevs. All rights reserved.
//
import UIKit
@loganwright
loganwright / IntrospectionExtensions.swift
Created November 24, 2014 20:31
Get properties from a swift object -- NSObject extension
extension NSObject {
class var propertyNames: [String] {
get {
var count: UInt32 = 0
let properties: UnsafeMutablePointer<objc_property_t> = class_copyPropertyList(self.classForCoder(), &count)
var propertyNames: [String] = []
for i in 0..<count {
let property: objc_property_t = properties[Int(i)]
if let name = String(UTF8String: property_getName(property)) {
propertyNames += [name]
@loganwright
loganwright / regionForCoords.m
Last active August 29, 2015 14:11 — forked from robmooney/gist:923301
Map Region Encompassing Coords w/ Padding
- (MKCoordinateRegion)regionForCoords:(NSArray *)coords withPaddingFactor:(CGFloat)paddingFactor {
CLLocationDegrees minLat = 90.0;
CLLocationDegrees maxLat = -90.0;
CLLocationDegrees minLon = 180.0;
CLLocationDegrees maxLon = -180.0;
for (NSValue *val in coords) {
CLLocationCoordinate2D coord = [val MKCoordinateValue];
if (coord.latitude < minLat) {
@loganwright
loganwright / LGTelephoneHandler.h
Last active August 29, 2015 14:12
LGTelephoneHandler
#import <Foundation/Foundation.h>
@interface MITTelephoneHandler : NSObject
+ (void)attemptToCallPhoneNumber:(NSString *)phoneNumber;
@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
#import <UIKit/UIKit.h>
@interface LGMarginLabel : UILabel
@property (nonatomic) UIEdgeInsets marginInsets;
@end
@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
@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 / 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 / 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)