Skip to content

Instantly share code, notes, and snippets.

View aratkevich's full-sized avatar
👋

ratkevich aratkevich

👋
View GitHub Profile
po [[UIApp keyWindow] recursiveDescription]
expr (void)[0x14b98920 setFrame:CGRectMake(70,40,150,25)]
po (void)[0x7852560 setClipsToBounds:NO]
po (void)[0x7852560 setFrame:(CGRect) { 13, 248, 295, 184 + 20 }]
po [0x7852560 setFrame:(CGRect) { 13, 248, 295, 184 + 37 }]
po (CGRect)[0x7852560 frame]
po (int)[ids count]
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
var view = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 00))
var image = UIImageView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
image.backgroundColor = #colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1)
image.contentMode = .scaleAspectFill
view.addSubview(image)
@aratkevich
aratkevich / ServiceLocating.swift
Created January 7, 2018 05:50
ServiceLocating
protocol ServiceLocating {
func getService<T>() -> T?
}
final class ServiceLocator: ServiceLocating {
private lazy var services: Dictionary<String, Any> = [:]
private func typeName(some: Any) -> String {
return (some is Any.Type) ?
"\(some)" : "\(some.dynamicType)"
}
@aratkevich
aratkevich / singleton.swift
Created January 7, 2018 05:31
Lazy singleton
static var shared: SomeManager {
guard let instance = SomeManager._shared else {
SomeManager._shared = SomeManager()
return SomeManager._shared!
}
return instance
}
@aratkevich
aratkevich / stronglyTyped.swift
Created September 4, 2017 18:34
Strongly typed identifiers
// Option 1
protocol Identity {
associatedtype Identifier
var id: Identifier {get set}
}
struct Person: Identity {
typealias Identifier = String
var id: Identifier
import Foundation
class SingletonC : NSObject {
class var sharedInstance : SingletonC {
struct Static {
static var onceToken : dispatch_once_t = 0
static var instance : SingletonC? = nil
}
dispatch_once(&Static.onceToken) {
@aratkevich
aratkevich / ssid.m
Created June 20, 2017 07:23
SSID wifi
NSString *ssid = nil;
NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());
for (NSString *ifnam in ifs) {
NSDictionary *info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam));
if (info[@"SSID"]) {
ssid = [info[@"SSID"] copy]
}
}
@aratkevich
aratkevich / ListInSwift.swift
Last active April 22, 2017 10:45
List in Swift
class Node<T> {
var value: T
weak var parent: Node?
var children: [Node] = []
init(value: T) {
self.value = value
}
func add(child: Node) {
@aratkevich
aratkevich / deleteSqlite.sh
Last active April 11, 2017 11:16
Скрипт delete sqlite
rm /Users/$(whoami)/Library/Developer/CoreSimulator/Devices/*/data/Containers/Data/Application/*/Library/Application\ Support/GiftLister.sqlite
@aratkevich
aratkevich / Скрипт TODO: FIXME:
Created April 11, 2017 06:51
Скрипт TODO: FIXME:
TAGS="TODO:|FIXME:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"