Skip to content

Instantly share code, notes, and snippets.

View nikolaykasyanov's full-sized avatar

Nikolai Kasyanov nikolaykasyanov

  • Careem
  • Berlin, Germany
View GitHub Profile
@nikolaykasyanov
nikolaykasyanov / grading.md
Last active May 4, 2016 16:18
FlixBus iOS coding challenge assessment criteria

FlixBus iOS coding challenge assessment

Primary criteria

ABSOLUTE MUST

  • Project builds & runs on required iOS versions
  • Date/times are displayed in correct timezone

Consistent code style

@import UIKit;
NS_ASSUME_NONNULL_BEGIN
@protocol MFBPreviewableCollectionView
- (nullable NSIndexPath *)mfb_previewableCollectionIndexPathForItemAtPoint:(CGPoint)point;
- (CGRect)mfb_previewableCollectionItemRectForIndexPath:(NSIndexPath *)indexPath;
import Swift
func LCS<T: Equatable>(a: [T], b: [T]) -> [[UInt]] {
let rows = a.count + 1
let cols = b.count + 1
var matrix: [[UInt]] = Array(count: rows, repeatedValue: Array(count: cols, repeatedValue: 0))
for i in 1..<rows {
@nikolaykasyanov
nikolaykasyanov / pre-commit
Last active March 28, 2023 12:36
Useful pre-commit hook for submodules
#!/bin/sh
if git status | grep -i 'HEAD detached' > /dev/null 2>&1; then
echo "You should not commit while in detached state, either create a new brach or checkout existing one before committing."
exit 1
fi
@nikolaykasyanov
nikolaykasyanov / maybe.swift
Last active February 3, 2018 23:27
Swift & Monads
// Make Optional a monad
extension Optional {
// Scala style, define `flatMap` directly
func flatMap<U>(f: (a: T) -> Optional<U>) -> Optional<U> {
switch (self) {
case .None: return nil
case .Some(let value): return f(a: value)
}
}
@nikolaykasyanov
nikolaykasyanov / RAC.swift
Last active August 29, 2015 14:02
Proof-of-concept typesafe RAC wrapper
protocol ISubscriber {
typealias Element
func disposable() -> RACCompoundDisposable
func sendNext(e: Element)
func sendError(e: NSError)
func sendCompleted()
}
@nikolaykasyanov
nikolaykasyanov / ReactiveCocoa.podspec
Last active August 29, 2015 14:01
podspec for ReactiveCocoa 3.0
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "3.0-dev"
s.summary = "A framework for composing and transforming streams of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "[email protected]" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :commit => "7fe93c972aed2dc1f1c9ac1b75cd955d1773fd35" }
s.license = 'MIT'
s.description = "ReactiveCocoa (RAC) is an Objective-C framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values."
@nikolaykasyanov
nikolaykasyanov / RAC-generator.m
Last active August 29, 2015 13:57
Poor man's generator using ReactiveCocoa 3.0
static RACSignal *BodyImageURLs(NSString *postBody)
{
NSRange (^lastRangeFromMatch)(NSTextCheckingResult *) = ^(NSTextCheckingResult *match) {
if (match == nil) {
return NSMakeRange(NSNotFound, 0);
}
else {
return [match rangeAtIndex:match.numberOfRanges - 1];
}
};
find . -name '*.p12' -depth 1 -type f | sed 's/^\.\/\(.\)/\1/' | xargs -I '{}' openssl pkcs12 -passin 'pass:' -in '{}' -out '{}'.pem -nodes
@nikolaykasyanov
nikolaykasyanov / update-all-profiles.sh
Last active August 29, 2015 13:56
Script for updating Apple provisioning profiles. Can be used on CI servers like Jenkins.
#!/bin/sh
function fetchProvisioningProfiles()
{
ios profiles:download:all --type development
DEVELOPMENT_RESULT=$?
if [ "$DEVELOPMENT_RESULT" -ne "0" ]; then
return 1
fi