Skip to content

Instantly share code, notes, and snippets.

View mergesort's full-sized avatar
😱
Very busy with life matters, will do my best to reply as soon as I can

Joe Fabisevich mergesort

😱
Very busy with life matters, will do my best to reply as soon as I can
View GitHub Profile
@mergesort
mergesort / gist:1581b738fba5d7b8f895
Last active August 29, 2015 14:12
Don't forget to force unwrap optionals when putting them into dictionaries which will be used not on iOS
func unauthenticatedUserSessionConfiguration() -> NSURLSessionConfiguration {
let base64Credentials = ("\(clientID):\(clientSecret)" as NSString).dataUsingEncoding(NSUTF8StringEncoding)
let encoded = base64Credentials?.base64EncodedDataWithOptions(NSDataBase64EncodingOptions(rawValue: 0))
var headers = Alamofire.Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders ?? [:]
headers["X-2FA-Support"] = "default"
// This is the key line. Note that it's an optional string.
headers["Authorization"] = "Basic \(NSString(data: encoded!, encoding: NSUTF8StringEncoding))"
@mergesort
mergesort / gist:245fa777d2e444fb82e2
Last active August 29, 2015 14:06
Can't get custom fonts to load once successfully registered with CTFontManagerRegisterGraphicsFont, help?
NSInteger const FontNotLoadedError = 101;
NSInteger const FontDoesNotExistError = 102;
NSString * const fontErrorDomain = @"FontError";
static NSDictionary *registeredFonts;
+ (UIFont *)customFontNamed:(NSString *)fontName size:(CGFloat)size
{
UIFont *font;
@mergesort
mergesort / gist:9966920
Last active August 29, 2015 13:58
Point within subview
//The subview is a view within an array of views.
//The array of views will be buttons, one of which should be the one being tapped.
//I'm trying to find the subview's position within it's superview, and then check which button is being tapped, and return that.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *result = [super hitTest:point withEvent:event];
for (UIView *subview in self.underneathViews)
{
@mergesort
mergesort / Singleton.m
Created March 17, 2014 18:08
The Perfect Singleton
A singleton which you can drop into any class without having to change a line of code no matter the class, no macros needed.
//.h
+ (instancetype)sharedRuntimeController;
//.m
+ (instancetype)sharedRuntimeController
{
static id _sharedRuntimeController = nil;
@mergesort
mergesort / podcasts.md
Last active January 4, 2016 10:49 — forked from orta/podcasts.md

Tech

  • The Critical Path - A podcast contemplating the causality of success and failure in the evolving story of mobile computing and related industries. Often a very insightful podcast on the landscape of technology.
  • Debug - Lots of interviews with ex-apple employees.
  • Novice No Longer - A new podcast about learning the ropes, which includes development, marketing, business, and other things you might not be well versed in.
  • Accidental Tech Podcast - A podcast about the weekly going ons in the tech world.

Security

  • Security Now - A podcast about all things security, from the man who coined the term spyware.