Skip to content

Instantly share code, notes, and snippets.

View fuzza's full-sized avatar
🎯
Focusing

Oleksii Faizullov fuzza

🎯
Focusing
View GitHub Profile
import Foundation
var model = Model(name: "Alex") // Model(name: "Alex")
model.name = "Hello" // error: cannot assign to property: 'name' setter is inaccessible
model[keyPath: \.name] = "Serge" // error: cannot assign through subscript: key path is read-only
let newModel = Model.lens.name.set("Serge")(model) // Model(name: "Serge")
@fuzza
fuzza / Additive.swift
Last active October 31, 2019 18:47
Generalized Mocks
protocol AutoMockable {}
protocol Additive: AutoMockable {
func add(a: Int, b: Int) -> Int
}
@fuzza
fuzza / Makefile
Created May 31, 2017 08:07 — forked from pietbrauer/Makefile
Shutdown and reset all iOS Simulators
erase_sim:
./reset_sim.sh 2>/dev/null; true
@fuzza
fuzza / AppDelegate.m
Last active May 14, 2016 18:13 — forked from oleksii-demedetskyi/AppDelegate.m
Service Locator
- didFinishAppLaunch
{
ServiceLocator* serviceLocator = [ServiceLocator new];
SomeService* someService = [SomeService new];
[serviceLocator useObject:someService asServiceForKind:[someService class]];
SomeViewController* vc = [SomeViewController new];
vc.serviceLocator = serviceLocator;
}
@fuzza
fuzza / UIImage+Resize.h
Created June 25, 2014 06:53
UIImage+Resize
// UIImage+Resize.h
// Created by Trevor Harmon on 8/5/09.
// Free for personal or commercial use, with or without modification.
// No warranty is expressed or implied.
// Extends the UIImage class to support resizing/cropping
@interface UIImage (Resize)
- (UIImage *)croppedImage:(CGRect)bounds;
- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize
transparentBorder:(NSUInteger)borderSize