Skip to content

Instantly share code, notes, and snippets.

View ronaldmannak's full-sized avatar

Ronald Mannak ronaldmannak

View GitHub Profile
0x0a16d2efbeef080a342a941aa99e505bd50df4f7
0xb81Df5747f39bfD5ce9410F1Be9B02851B0cbd6E
@ronaldmannak
ronaldmannak / NetworkManager.swift
Last active January 28, 2019 06:35
Proof of concept for Connecting to the BMW Connect server using SSL certificate pinning. Assumes you have copied GlobalSignOrganizationValidationCA-SHA256-G2.cer from the Connected Drive iOS app bundle
import Foundation
final class NetworkManager: NSObject, URLSessionDelegate {
func login() {
var request = URLRequest(url: URL(string: "https://b2vapi.bmwgroup.com/webapi/oauth/token/")!)
request.addValue("Content-Type", forHTTPHeaderField: "application/json")
request.httpMethod = "GET"
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: nil)

Keybase proof

I hereby claim:

  • I am ronaldmannak on github.
  • I am ronaldmannak (https://keybase.io/ronaldmannak) on keybase.
  • I have a public key whose fingerprint is 86E0 A3DE 989F DF25 E164 C736 739A DDBB EE88 35BE

To claim this, I am signing this object:

@ronaldmannak
ronaldmannak / gist:b2a126fe746732a730f9
Created September 28, 2014 23:21
Trying to solve conflicting names of functions and properties in Swift. How do I call the function position() from within a class that has a property with the same name?
import SpriteKit
func position(number: Int)->Int {
return number
}
class node: SKNode {
// Note: SKNode has a property called position (a CGPoint)
@ronaldmannak
ronaldmannak / gist:4b8c1e7c03c7cffe238e
Last active August 29, 2015 14:02
Behold the Quantum-Array: Arrays in Swift seem to be behaving like a struct and object, depending on the operation performed on the array. Open this gist in a playground. See https://twitter.com/ronaldmannak/status/474706423310340096 Update 6/6/2014: made example easier to read, removed irrelevant code, and added response from an Apple engineer.…
let anArray = [1, 2, 3] // A constant array
let anotherArray = anArray // make anotherArray point to anArray
anArray === anotherArray // true. anArray points to anotherArray
// Let's try the same with a variable array
var aMutableArray = [4, 5, 6]
var anotherMutableArray = aMutableArray // Should work like constant arrays, but...
anotherMutableArray === aMutableArray // Surprise: this returns false
// Update: According to an Apple engineer, this is a compiler bug.
// JLRoutes delay
// In this version, the viewcontroller appears instantaneously
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *rootStoryboard = [UIStoryboard storyboardWithName:@"MainFeed" bundle:nil];
UIViewController *rootvc = [rootStoryboard instantiateInitialViewController];
self.window.rootViewController = rootvc;
return YES
@ronaldmannak
ronaldmannak / NSNull+behave.m
Last active December 11, 2015 02:48
Making NSNull behave like nil. See blog post ronaldmannak.github.com/2013/01/14/nsnull.html
//
// NSNull+behave.m
//
// Created by Ronald Mannak on 1/2/13.
// Copyright (c) 2013 Ronald Mannak. All rights reserved.
//
@implementation NSNull (catch)
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
-(NSString*)dailyLanguage:(NSTimeInterval) overdueTimeInterval{
if (overdueTimeInterval<0)
overdueTimeInterval*=-1;
NSInteger minutes = round(overdueTimeInterval)/60;
NSInteger hours = minutes/60;
NSInteger days = hours/24;
NSInteger months = days/30;
NSInteger years = months/12;