Skip to content

Instantly share code, notes, and snippets.

View stinger's full-sized avatar

Ilian Konchev stinger

View GitHub Profile
@stinger
stinger / gist:19bb9b9940c2be828b3703429c5ddeec
Created December 12, 2016 07:58 — forked from maxkandler/gist:5233150
Hide the iTerm2 Dock icon.
/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
import Foundation
import UIKit
// Usage Examples
let shadowColor = Color.shadow.value
let shadowColorWithAlpha = Color.shadow.withAlpha(0.5)
let customColorWithAlpha = Color.custom(hexString: "#123edd", alpha: 0.25).value
enum Color {
@stinger
stinger / RxSwiftMVVMViewSinks.swift
Created January 2, 2017 15:05
RxSwift MVVM view sinks
class MyCustomView : UIView {
var sink : AnyObserver<SomeComplexStructure> {
return AnyObserver { [weak self] event in
switch event {
case .next(let data):
self?.something.text = data.property.text
break
case .error(let error):
self?.backgroundColor = .red
@stinger
stinger / RxSwiftMVVM.swift
Created January 2, 2017 15:07
RxSwift MVVM
import RxSwift
// -- View Model
struct LoginViewModel {
var username = Variable<String>("")
var password = Variable<String>("")
var isValid : Observable<Bool>{
return Observable.combineLatest( self.username, self.password)
#set the shell to /bin/sh
TAGS="TODO:|FIXME:"
find "${SRCROOT}" \( -name "*.swift" \) -type f -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
@stinger
stinger / RxCollectionViewSectionedAnimatedDataSourceExample.swift
Created March 28, 2017 09:53
RxCollectionViewSectionedAnimatedDataSource example with multiple cells types
import UIKit
import RxSwift
import RxCocoa
import RxDataSources
class ViewController: BaseCollectionViewController {
...
typealias Section = AnimatableSectionModel<String, CellStyle>
var fetchedResultsProcessingOperations: [NSBlockOperation] = []
private func addFetchedResultsProcessingBlock(processingBlock:(Void)->Void) {
fetchedResultsProcessingOperations.append(NSBlockOperation(block: processingBlock))
}
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
switch type {
case .Insert:
@stinger
stinger / Swift4CodableDates.swift
Created August 21, 2017 13:57
Swift 4: Codable dates
import Foundation
struct LocationData: Codable {
var city: String
var country: String
var address: String?
}
struct Item: Codable {
var name: String
@stinger
stinger / InfinityLoader.swift
Created March 23, 2018 08:18
InfinityLoader swift demo
import UIKit
import PlaygroundSupport
public class InfinityLoader: UIView {
let anim = CAAnimationGroup()
//// Drawing Methods
lazy var path: UIBezierPath = {
@stinger
stinger / DataLoading.swift
Created April 3, 2018 20:40
Data loading using protocols
import UIKit
import PlaygroundSupport
enum CoreError: Error, LocalizedError {
case unknown
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error occured"