View UIScreen+Orientation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIScreen { | |
var orientation: UIInterfaceOrientation { | |
let convertedZeroPoint = fixedCoordinateSpace.convert(CGPoint.zero, to: coordinateSpace) | |
let coordinateSpaceBounds = coordinateSpace.bounds | |
switch convertedZeroPoint { | |
case .zero: | |
return .portrait | |
case CGPoint(x: coordinateSpaceBounds.maxX, y: coordinateSpaceBounds.minY): | |
return .landscapeLeft | |
case CGPoint(x: coordinateSpaceBounds.minX, y: coordinateSpaceBounds.maxY): |
View gist:30e2cc17f1179251d2c4df8b86384036
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let s = """ | |
aview.snp.makeConstraints { (make) -> Void in | |
make.centerX.equalTo(view.snp.centerX) | |
make.bottom.equalTo(anotherview.snp.top).offset(-10) | |
make.height.equalTo(40) | |
make.width.equalTo(view.snp.width) | |
} |
View homework.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
print("Type your age: ") | |
if let input = readLine() { | |
print("You typed \(input)\n") | |
} | |
print("Type your birth year: ") |
View DynamicObject.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@dynamicMemberLookup | |
class DynamicObject: NSObject { | |
subscript<T>(dynamicMember member: String) -> T? { | |
get { | |
return objc_getAssociatedObject(self, member) as? T | |
} | |
set { |
View M.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dynamicMemberLookup | |
@dynamicCallable | |
struct M { | |
subscript(dynamicMember member: String) -> M { | |
get { | |
return self | |
} | |
set { | |
} |
View playground.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func address(o: UnsafeRawPointer) -> Int { | |
return Int(bitPattern: o) | |
} | |
func addressHeap<T: AnyObject>(o: T) -> Int { | |
return unsafeBitCast(o, to: Int.self) | |
} | |
//////////////////////////////////////////// |
View gist:5abac51b2ef516cb7b057055e120213c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Theme { | |
case light | |
case dark | |
} |
View test.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder