Skip to content

Instantly share code, notes, and snippets.

View sssbohdan's full-sized avatar
❤️

Bohdan Savych sssbohdan

❤️
View GitHub Profile
@sssbohdan
sssbohdan / debounce-throttle.swift
Last active January 17, 2019 09:19 — forked from simme/debounce-throttle.swift
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Bohdan Savych on 19/12/18.
// License: MIT
//
import Foundation
extension TimeInterval {
@sssbohdan
sssbohdan / 1-Functor-and-Monad.md
Created October 8, 2017 19:01 — forked from mbrandonw/1-Functor-and-Monad.md
Swift Functor and Monad

Copy and paste the swift code below into a playground to experiment.

This is a very close emulation of Functor and Monad typeclasses in swift. However, it is very fragile (i.e. easy to crash the compiler).

For example, instance methods of fmap will run fine, but attempting to use a globally defined fmap that acts on Functor types will cause a crash. Similarly for bind. Unfortunately this means we cannot define the nice infix operator versions of these functions.

import UIKit
import RxSwift
import RxCocoa
let requiredUserNameLength = 5
let requiredPasswordLength = 5
let limitUserNameLength = 20
class ValidationViewController: UIViewController {
@sssbohdan
sssbohdan / introrx.md
Created June 24, 2017 19:53 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@sssbohdan
sssbohdan / CovarianceContravariance.swift
Created June 22, 2017 20:41 — forked from pedrocid/CovarianceContravariance.swift
Examples os covariance and contravariance in Swift
//MARK: From https://mikeash.com/pyblog/friday-qa-2015-11-20-covariance-and-contravariance.html
import UIKit
//MARK: TYPE VARIANCE LESSON
//First we explore supertypes and subtypes
class Thing {}
class Vehicle: Thing {}
@sssbohdan
sssbohdan / iOS.8.3.txt
Created March 13, 2017 12:43
iOS UIFont names
UIFont: family Thonburi
UIFont: font Thonburi-Bold
UIFont: font Thonburi
UIFont: font Thonburi-Light
UIFont: family Khmer Sangam MN
UIFont: font KhmerSangamMN
UIFont: family Snell Roundhand
UIFont: font SnellRoundhand-Black
UIFont: font SnellRoundhand-Bold
UIFont: font SnellRoundhand
@sssbohdan
sssbohdan / contact.m
Created December 14, 2016 11:41 — forked from willthink/contact.m
Using CNContactStore in Objective C to query contacts info
#import <Contacts/Contacts.h>
@implementation ContactsScan
- (void) contactScan
{
if ([CNContactStore class]) {
//ios9 or later
CNEntityType entityType = CNEntityTypeContacts;
if( [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusNotDetermined)