Skip to content

Instantly share code, notes, and snippets.

View alexkent's full-sized avatar

alex kent alexkent

  • Bontouch
  • Östersund
View GitHub Profile
@alexkent
alexkent / trivialCertValidator
Last active August 29, 2015 14:04
This is probably a bad idea, but I am not sure why: SSL pinning by comparing certificate data.
- (id)initWithCertificatePath:(NSString *)path
{
self = [super init];
if (self) {
_certData = [NSData dataWithContentsOfFile:path];
}
return self;
}
- (void)validateChallenge:(NSURLAuthenticationChallenge *)challenge {
workspace 'Everything.xcworkspace'
platform :ios, "7.0"
xcodeproj './App/My App.xcodeproj'
xcodeproj './Framework1/Framework1.xcodeproj'
xcodeproj './Framework2/Framework2.xcodeproj'
#### Application
var iExist:String?
var s:[String:Any] = [String:Any]()
s["thing"] = 2
if let x = s["thing"] {
iExist = x
}
// explicit cast x
import Foundation
public class Thing: NSObject {
public enum State {
case yes, no, maybe
}
public var state:State
internal init() {
import Foundation
class foo {
var bar:String!
func print() {
println("some stuff and \(self.bar)")
}
import Cocoa
class Thing:NSObject {
func a() {
println("a")
}
}
extension Thing {
// func a() {
@alexkent
alexkent / gist:7573141750237fcfc258
Created September 4, 2014 11:32
swift method argument names are weird with blocks
import Foundation
class Thing {
func doStuff(stuff:String) {
}
func doStuffWithAThing(stuff:String, athing:String) {
}
func doStuffWithTwoThings(stuff:String, thingOne:String, thingTwo:String) {
import Foundation
var strings = ["one", "two", "three", "four"]
extension Array {
func mapFilter<U>(transform: (T) -> U?) -> [U] {
var o = [U]()
for e in self {
extension NSObject {
func typeNameWithOutModuleName() -> String {
var typeNameHeirarchy = NSStringFromClass(self.dynamicType).componentsSeparatedByString(".")
typeNameHeirarchy.removeFirst()
return typeNameHeirarchy.joinWithSeparator(".")
}
}
xcrun llvm-cov report -use-color=true -instr-profile \
./Build/Intermediates/CodeCoverage/Coverage.profdata \
./Build/Intermediates/CodeCoverage/MyApp/Products/Debug-iphonesimulator/MyApp.app/MyApp