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 / 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 / DynamicObject.swift
Created Apr 24, 2019
DynamicObject.swift
View DynamicObject.swift
import Foundation
@dynamicMemberLookup
class DynamicObject: NSObject {
subscript<T>(dynamicMember member: String) -> T? {
get {
return objc_getAssociatedObject(self, member) as? T
}
set {
View M.swift
@dynamicMemberLookup
@dynamicCallable
struct M {
subscript(dynamicMember member: String) -> M {
get {
return self
}
set {
}
@T-Pham
T-Pham / playground.swift
Created Oct 19, 2018
Swift - in-place mutation
View playground.swift
func address(o: UnsafeRawPointer) -> Int {
return Int(bitPattern: o)
}
func addressHeap<T: AnyObject>(o: T) -> Int {
return unsafeBitCast(o, to: Int.self)
}
////////////////////////////////////////////
@T-Pham
T-Pham / test.swift
Last active Sep 3, 2018
url regex :(
View test.swift
import Foundation
let qqq = "https://yahoo.com/:;(&;&:93@;&:&&:'’'"
NSURL(string: qqq)
let tests = [
("google.com", true),
("www.google.com", true),
("http://google.com", true),
("http://www.google.com", true),
View BoomClap.json
{"data":[{"author":{"name":"Aleks","picture":{"s":"https://bandlab-test-images.azureedge.net/v1.0/Users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/360x360","m":"https://bandlab-test-images.azureedge.net/v1.0/Users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/640x640","l":"https://bandlab-test-images.azureedge.net/v1.0/Users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/1024x1024","xs":"https://bandlab-test-images.azureedge.net/v1.0/Users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/100x100","url":"https://bandlab-test-images.azureedge.net/v1.0/users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/"}},"createdOn":"2016-09-23T08:15:13Z","modifiedOn":"2016-09-23T08:15:13Z","picture":{"s":"https://bandlab-test-images.azureedge.net/v1.0/Users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/360x360","m":"https://bandlab-test-images.azureedge.net/v1.0/Users/71c81538-4e88-e511-80c6-000d3aa03fb0/636016633463395803/640x640","l":"https://bandlab-test-images.az
View Disco.brs
sub init()
n = 50
m.n = n
for i = 0 to n * n - 1
c = i mod n + 1
r = Int(i / n) + 1
child = CreateObject("roSGNode", "Rectangle")
w = Int(1280 / n)
h = Int(720 / n)
child.width = w
@T-Pham
T-Pham / base64.txt
Created Jun 6, 2017
Base64 test string
View base64.txt
eyJhIjoiPGE+Pz8/In0=
You can’t perform that action at this time.