Skip to content

Instantly share code, notes, and snippets.

View nikolaykasyanov's full-sized avatar

Nikolai Kasyanov nikolaykasyanov

  • Careem
  • Berlin, Germany
View GitHub Profile
anonymous
anonymous / NSStringVariations.m
Created February 18, 2015 08:32
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
void (^benchmark)(const char *str) = ^(const char *str) {
const long count = 10000000;
NSDate *start = [NSDate date];
for (long i = 0; i < count; i++) {
(void)[[NSString alloc] initWithUTF8String:str];
}
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active March 19, 2025 07:02
The best FRP iOS resources.

Videos

@interface PSPDFWindow ()
@property (nonatomic, strong) UIViewController *realRootViewController;
@end
@implementation PSPDFWindow
- (void)setHidden:(BOOL)hidden {
[super setHidden:hidden];
// Workaround for rdar://19592583
@airspeedswift
airspeedswift / COWTree.swift
Last active March 5, 2017 13:20
Swift copy-on-write behaviour for a struct using HeapBuffer
// ideally we would define this inside the tree struct
private class _Node<T: Comparable> {
var _value: T
var _left: _Node<T>? = nil
var _right: _Node<T>? = nil
init(value: T) { _value = value }
}
@cdzombak
cdzombak / tgmath.md
Last active July 14, 2016 18:01
fucking tgmath doesn't work with ObjC modules, and Apple has known about this for at least a year and doesn't care about fixing it
@steipete
steipete / gist:20d04053344b3cb36056
Created November 29, 2014 19:19
Quite a lot of calls happening for a simple modal view controller presentation.
-> <ViewController:0x79634cd0>: -[UIViewController presentViewController:<NavigationController: 0x7ba7dab0> animated:1 completion:(null)]
--> <ViewController:0x79634cd0>: -[UIViewController _transitionCoordinator]
---> <ViewController:0x79634cd0>: -[UIViewController _presentationController]
===> (null)
---> <ViewController:0x79634cd0>: -[UIViewController presentedViewController]
----> <ViewController:0x79634cd0>: -[UIViewController childModalViewController]
====> (null)
===> (null)
---> <ViewController:0x79634cd0>: -[UIViewController childModalViewController]
===> (null)
@mattt
mattt / nshipster-new-years-2015.md
Created November 25, 2014 19:38
NSHipster New Year's 2015

Season's Greetings, NSHipsters!

As the year winds down, and we take a moment to reflect on our experiences over the past months, one thing is clear: 2014 has been an incredible year professionally for Apple developers. So much has happened in such a short timespan, and yet it's hard to remember our relationship to Objective-C before Swift, or what APIs could have captivated our imagination as much as iOS 8 or WatchKit.

It's an NSHipster tradition to ask you, dear readers, to send in your favorite tips and tricks from the past year for publication over the New Year's holiday. This year, with the deluge of new developments—both from Cupertino and the community at large—there should be no shortage of interesting tidbits to share.

Submit your favorite piece of Swift or Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!

If you're wondering about what to post, look to

@jaredru
jaredru / RACSignal+ShareWhileActiveBackport.m
Last active June 30, 2017 02:09
A ReactiveCocoa 2.x `-shareWhileActive` backport
- (RACSignal *)shareWhileActive {
NSRecursiveLock *lock = [[NSRecursiveLock alloc] init];
lock.name = @"com.github.ReactiveCocoa.shareWhileActive";
// These should only be used while `lock` is held.
__block NSUInteger subscriberCount = 0;
__block RACDisposable *underlyingDisposable = nil;
__block RACReplaySubject *inflightSubscription = nil;
return [[RACSignal
@andymatuschak
andymatuschak / CollectionViewDataSource.swift
Last active February 12, 2021 09:44
Type-safe value-oriented collection view data source
//
// CollectionViewDataSource.swift
// Khan Academy
//
// Created by Andy Matuschak on 10/14/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
@evancz
evancz / Architecture.md
Last active December 21, 2022 14:28
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo