Skip to content

Instantly share code, notes, and snippets.

View jstart's full-sized avatar
💭
Learning SwiftUI... slowly

Christopher Truman jstart

💭
Learning SwiftUI... slowly
View GitHub Profile
class Client {
var baseURL = "http://dev.whatever.com/"
func execute(request : Request, completionHandler: (Response<AnyObject, NSError>) -> Void){
Alamofire.request(request.method, baseURL + request.path, parameters: request.parameters())
.responseJSON { response in
completionHandler(response)
}
}
}
import Alamofire
protocol Request {
var path : String { get }
var method : Method { get }
func parameters() -> [String : AnyObject]
}
struct AuthRequest : Request {
let path = "auth"
{"data":{"pricingTiers":[{"tierStem":"0","tierName":"Free","pricingInfo":[{"country":"United States","countryCode":"US","currencySymbol":"$","currencyCode":"USD","wholesalePrice":0.00,"retailPrice":0.00,"fRetailPrice":"$0.00","fWholesalePrice":"$0.00"},{"country":"Canada","countryCode":"CA","currencySymbol":"$","currencyCode":"CAD","wholesalePrice":0.00,"retailPrice":0.00,"fRetailPrice":"$0.00","fWholesalePrice":"$0.00"},{"country":"Mexico","countryCode":"MX","currencySymbol":"$","currencyCode":"MXN","wholesalePrice":0.00,"retailPrice":0.00,"fRetailPrice":"$0.00","fWholesalePrice":"$0.00"},{"country":"Australia","countryCode":"AU","currencySymbol":"$","currencyCode":"AUD","wholesalePrice":0.00,"retailPrice":0.00,"fRetailPrice":"$0.00","fWholesalePrice":"$0.00"},{"country":"New Zealand","countryCode":"NZ","currencySymbol":"$","currencyCode":"NZD","wholesalePrice":0.00,"retailPrice":0.00,"fRetailPrice":"$0.00","fWholesalePrice":"$0.00"},{"country":"Japan","countryCode":"JP","currencySymbol":"¥","currencyCode":"
@jstart
jstart / UIStackViewAlignment.swift
Created August 4, 2015 23:19
UIStackViewAlignment
enum UIStackViewAlignment : Int {
case Fill
case Leading
static var Top: UIStackViewAlignment { get { return .Leading} }
case FirstBaseline
case Center
case Trailing
static var Bottom: UIStackViewAlignment { get{ return .Trailing} }
case LastBaseline
}
@jstart
jstart / UIStackViewDistribution.swift
Created August 4, 2015 23:18
UIStackViewDistribution
enum UIStackViewDistribution : Int {
case Fill
case FillEqually
case FillProportionally
case EqualSpacing
case EqualCentering
}
@jstart
jstart / pggrep.swift
Last active August 29, 2015 14:23 — forked from erica/pggrep.swift
//
// main.swift
// pggrep
//
// Created by Erica Sadun on 6/17/15.
// Copyright © 2015 Erica Sadun. All rights reserved.
//
import Foundation
//
// main.swift
// pggrep
//
// Created by Erica Sadun on 6/17/15.
// Copyright © 2015 Erica Sadun. All rights reserved.
//
import Foundation
@jstart
jstart / gist:035d7dcdc47166416512
Created May 21, 2015 18:52
Jack Flintermann's lovely mug
//
// SNGUserPhotosController.m
// Singles-eHarmony
//
// Created by Jack Flintermann
// Copyright (c) 2012 eHarmony. All rights reserved.
//
//
// 77$Z8DD88O8ZZOZ7II77II?????+++++++====================+=++++++?????7?I77O$$777II
// $7$O8D8O88OZ$$77IIIII????++++++++=======================++++++??????II77$$$77III
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
function has_compatibility() {
@jstart
jstart / touchID
Last active July 28, 2017 17:58
Touch ID Example
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Authenticate using your finger";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"User is authenticated successfully");
} else {