Skip to content

Instantly share code, notes, and snippets.

🖖
Hi!

Thanh Pham T-Pham

🖖
Hi!
Block or report user

Report or block T-Pham

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@T-Pham
T-Pham / MyButton.swift
Last active Aug 15, 2019
Custom UIControlState
View MyButton.swift
class MyButton: UIButton {
var error: Bool = false {
didSet {
setNeedsLayout()
}
}
override var state: UIControlState {
get {
@T-Pham
T-Pham / DeviceOptimizer.swift
Last active Aug 15, 2016
Convenient Swift method to run a closure of UI-optimizing code on some devices selectively based on their logical height
View DeviceOptimizer.swift
//
// DeviceOptimizer.swift
//
// Created by Thanh Pham on 8/4/16.
//
import UIKit
struct DeviceOptimizer {
View keybase.md

Keybase proof

I hereby claim:

  • I am t-pham on github.
  • I am tpham (https://keybase.io/tpham) on keybase.
  • I have a public key ASB2senYAAcq9Q0QhoCtDhc6fYJfbt1QTEsA8X7CZJi5fwo

To claim this, I am signing this object:

@T-Pham
T-Pham / tree.swift
Last active Jul 25, 2016
Mirror tree without recursion
View tree.swift
class Node {
var id = 0
weak var parent: Node? = nil
var left: Node? = nil {
didSet {
left?.parent = self
}
}
var right: Node? = nil {
didSet {
@T-Pham
T-Pham / MacroFunctions.swift
Last active Jul 22, 2016
A wrapper function for Swift conditional compilation statements
View MacroFunctions.swift
//
// MacroFunctions.swift
//
// Created by Thanh Pham on 7/22/16.
//
func ifNotDebugDo(@noescape closure: Void -> Void) {
#if !DEBUG
closure()
#endif
@T-Pham
T-Pham / SimplifiedCode.swift
Last active May 18, 2019
Checking array type issue in Swift
View SimplifiedCode.swift
import Foundation
// Alamofire
enum AlamofireReponse<T, E> {
case Success(T)
case Failure(E)
}
func responseJSON(alamofireReponse: AlamofireReponse<AnyObject, NSError> -> Void) {
alamofireReponse(.Success([["type": "not_object"], ["type": "not_object"]]))
@T-Pham
T-Pham / AlamofireSwiftyJSONSerializer.swift
Last active Mar 15, 2017
Alamofire SwiftyJSON Serializer
View AlamofireSwiftyJSONSerializer.swift
//
// AlamofireSwiftyJSONSerializer.swift
//
// Created by Thanh Pham on 7/21/16.
//
import Alamofire
import SwiftyJSON
extension Request {
You can’t perform that action at this time.