Skip to content

Instantly share code, notes, and snippets.

View PR_TEMPLATE
{title} (#{id})
{sourceBranch} => {targetBranch}
{description}
{approvedByList}
@initFabian
initFabian / RoutersProtocol.swift
Last active Jun 6, 2020
Complete basic router version of RoutesProtocol.swift that contains all the code along with comments.
View RoutersProtocol.swift
//
// RoutesProtocol.swift
// RoutableApp
//
// Created by Fabian Buentello on 11/29/16.
// Copyright © 2016 ChaiOne. All rights reserved.
//
import Alamofire
View FinalRouter.swift
//Router.swift, Fabian's entire file
struct Router: URLRouter {
static var basePath: String {
return "https://private-85a46-routable.apiary-mock.com/"
}
struct User: Readable, Creatable, Updatable,
hasStatuses, hasPictures, hasPosts {
var route: String = "users"
var urlParams: String!
@initFabian
initFabian / AlamofireRouterExample_Extended.swift
Last active Jun 6, 2020
An Alamofire router example used in a post, https://chaione.com/blog/rethinking-routers-swift-protocol-oriented-programming-part-1, to show how a router with multiple paths would look like.
View AlamofireRouterExample_Extended.swift
// Router.swift
import Alamofire
enum Router: URLRequestConvertible {
static let baseURLString = "https://private-85a46-routable.apiary-mock.com/"
case readUsers
case createUser(parameters: Parameters)
View typealiasQuestion.swift
typealias nested1Dictionary = [ String : AnyObject ]
typealias nested2Dictionary = [ String : nested1Dictionary ]
typealias nested3Dictionary = [ String : nested2Dictionary ]
typealias nested4Dictionary = [ String : nested3Dictionary ]
let parameters2: nested2Dictionary = ["data": ["attributes": jsonData]]
let parameters3: nested3Dictionary = [ "data": [ "attributes" : jsonData ]]
let parameters4: nested4Dictionary = ["data": ["attributes": ["data": jsonData]]]
View ChainableURLString.swift
/*
* Chainable Url String example
* Run in Playground
*/
private var baseURL = "www.example.com"
struct AppURL {
struct User: CustomStringConvertible {
View gist:9c61052e66891dc48d5a
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell
{
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("CELL", forIndexPath: indexPath) as CollectionCell
//using titleLabel as an example
if (_cell.titleLabel != nil) {
print("cell being reused")
} else {
// ....
@initFabian
initFabian / _fix_tutorial.py
Last active Aug 29, 2015
possible fix for sentdex
View _fix_tutorial.py
for file in each_file:
date_stamp = datetime.strptime(file, '%Y%m%d%H%M%S.html')
unix_time = time.mktime(date_stamp.timetuple())
full_file_path = each_dir+'/'+file
# read file
source = open(full_file_path, 'r').read()
try:
# DONT typecast to float
You can’t perform that action at this time.