Skip to content

Instantly share code, notes, and snippets.

View kostiakoval's full-sized avatar

Kostiantyn Koval kostiakoval

View GitHub Profile
@kostiakoval
kostiakoval / uncrustify-objc.cfg
Created September 7, 2016 11:35 — forked from defagos/uncrustify-objc.cfg
My Objective-C Uncrustify configuration file
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment
@kostiakoval
kostiakoval / Valentine.swift
Created February 14, 2016 12:05
Valentine Day
import UIKit
import XCPlayground
let a = 10
let layer = CAShapeLayer()
layer.strokeColor = UIColor.redColor().CGColor
layer.fillColor = UIColor(red: 1, green: 0.33, blue: 0.33, alpha: 1).CGColor
layer.lineWidth = 12
@kostiakoval
kostiakoval / Foo2.swift
Created November 17, 2015 13:38
Init Functionality proposal for http://merowing.info/2015/11/swift-init/
class Foo2 {
let controller: UIViewController = Foo2.setupController()
let window: UIWindow = Foo2.setupWindow()
}
private extension Foo2 {
static func setupController() -> UIViewController {
return UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
}
@kostiakoval
kostiakoval / String+RangeOf.swift
Last active February 13, 2016 16:45
Pure Swift rangeOf String
// MARK: - String
extension String {
func rangeOf(x: String) -> Range<Index>? {
return characters.rangeOf(x.characters)
}
}
extension String.CharacterView {
@kostiakoval
kostiakoval / NSClassFromString.swift
Last active March 15, 2017 23:55
NSClassFromString in playground!
import Foundation
class Playground : NSObject {
static var bundleVersion: String {
let s = self.description().stringByReplacingOccurrencesOfString(".Playground", withString:"")
return s
}
}
let version = Playground.bundleVersion
@kostiakoval
kostiakoval / SafeDictionany.swift
Created July 17, 2015 13:34
Static Safe keys mapping
//: Playground - noun: a place where people can play
import UIKit
var remoteKeys = ["Play", "Stop"]
var LocalKyes = ["1", "2"]
/// Code 1
var keys = [
extension Dictionary {
init(_ elements: [Element]){
self.init()
for (k, v) in elements {
self[k] = v
}
}
func map<U>(transform: Value -> U) -> [Key : U] {
return Dictionary<Key, U>(Swift.map(self, { (key, value) in (key, transform(value)) }))
@kostiakoval
kostiakoval / SpeedLog-post-4.swift
Last active December 12, 2015 10:58
SpeedLog-post-4
func testFunc() {
for i in 0...100 {
let y = i * 10
SpeedLog.print(y)
}
}
testFunc()
@kostiakoval
kostiakoval / SpeedLog-post-3.swift
Last active December 12, 2015 10:56
SpeedLog-post-3
func testFunc() {
for i in 0...100 {
let y = i * 10
#if DEBUG
print(y)
#endif
}
}
testFunc()
@kostiakoval
kostiakoval / SpeedLog-post-2.swift
Last active December 12, 2015 10:54
SpeedLog-post-2
func testFunc() {
for i in 0...100 {
let y = i * 10
print(y)
}
}
testFunc()