Skip to content

Instantly share code, notes, and snippets.


Nikolay Kasyanov nikolaykasyanov

View GitHub Profile
nikolaykasyanov / Example.swift
Last active Sep 27, 2019
A property wrapper that creates subject-backed observers (RxSwift)
View Example.swift
class ViewModel {
init() {
// accessing underlying subject:
// look ma, no explicit subject property
View do you even retain

Self в Swift и Objective-C

Дисклеймер: речь идёт об однопоточном коде, оставим ужасы параллельного исполнения за скобками. Также не рассматривается возможность overrelease.


Объект точно не ритейнится на время выполнения его метода, пруфы:

View DoYouEvenRetainSelf.m
#import <Foundation/Foundation.h>
@interface Node: NSObject
@property (nonatomic, weak) Node *parent;
@property (nonatomic) NSArray *children;
@implementation Node {
View DoYouRetainSelf.swift
import Foundation
class Child {
deinit {
var parent: Parent?
func removeFromParent() {
nikolaykasyanov / cmake.rb
Created Feb 4, 2019
CMake 3.12.4 formula
View cmake.rb
class Cmake < Formula
desc "Cross-platform make"
homepage ""
url ""
sha256 "5255584bfd043eb717562cff8942d472f1c0e4679c4941d84baadaa9b28e3194"
head ""
bottle do
cellar :any_skip_relocation
sha256 "7bcd5ae043d2a6fd5983b026ccdc70b7594e0dbe9de4d367cfcead7edf3c8596" => :mojave
View Dependencies.swift
protocol RemoteAPIDelegate: class {
func remoteAPIDidLoadPosts(_ posts: NSArray)
class RemoteAPI {
weak var delegate: RemoteAPIDelegate?
func loadPosts() {
View ExternalService.swift
protocol ReachabilityDelegate: class {
func reachabilityDidChange(_ reachable: Bool)
class Reachability {
weak var delegate: ReachabilityDelegate?
class Model: ReachabilityDelegate {
func reachabilityDidChange(_ reachable: Bool) {
nikolaykasyanov / C138FB1B-8C83-477C-B33C-05551516167A.codesnippet
Last active Nov 27, 2016
__auto_type autocompletion snippet for Xcode 8+. Just put it in ~/Library/Developer/Xcode/UserData/CodeSnippets/ and then start typing aut... in Xcode.
View C138FB1B-8C83-477C-B33C-05551516167A.codesnippet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
View mfb_latest_hockey_build.rb
require 'json'
require 'net/http'
module Fastlane
module Actions
class MfbLatestHockeyBuildAction < Action
host_uri = URI.parse('')
http =, host_uri.port)
http.use_ssl = true
View AssociatedHype.swift
public protocol DBWorker2 {
associatedtype S: SequenceType
func fetchObjectsFromStorage(type: S.Generator.Element.Type) -> Observable<S.Generator.Element>
func saveObjectsToStorage(objects: S) -> Observable<Void>
public class DBWorker2Impl: DBWorker2 {
public func fetchObjectsFromStorage(type: Item.Type) -> Observable<Item> {
return Observable()