Skip to content

Instantly share code, notes, and snippets.

@victor-pavlychko
victor-pavlychko / swift-responder-chain.swift
Created May 31, 2016 17:36 — forked from anandabits/swift-responder-chain.swift
A minimalist responder chain implemented in pure Swift
// Created by Matthew Johnson on 5/28/16.
// Copyright © 2016 Anandabits LLC. All rights reserved.
//
// This is a minimalist implementation of a responder chain in pure Swift.
//
// It is not intended to demonstrate the best way to
// implement event processing in Swift.
//
// The intent is to show how little code is necessary to acheive behavior
// similar to Cocoa's responder chain in pure Swift.
/*
ericasadun.com
Sometimes letting go doesn't mean saying goodbye
*/
prefix operator ++
prefix operator --
postfix operator ++
@victor-pavlychko
victor-pavlychko / config.fish
Created November 23, 2015 11:33
fish-theme.fish
set -g fish_color_autosuggestion gray
set -g fish_color_command purple
set -g fish_color_comment brown
set -g fish_color_cwd green
set -g fish_color_cwd_root red
set -g fish_color_error red
set -g fish_color_escape cyan
set -g fish_color_history_current cyan
set -g fish_color_match cyan
set -g fish_color_normal normal
@victor-pavlychko
victor-pavlychko / Hero4BlackWifi.md
Created April 19, 2017 18:23 — forked from KonradIT/Hero4BlackWifi.md
Wifi hacking for HERO4 Black
@victor-pavlychko
victor-pavlychko / ZIndexedView.swift
Last active July 31, 2017 09:23
UIView extension to maintain z-ordering in a superview
//
// ZIndexedView.swift
//
// Created by Victor Pavlychko on 7/30/17.
// Copyright © 2017. All rights reserved.
//
import UIKit
public protocol ZIndexed {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
switch segue.destination {
case let destination as AnotherViewController:
destination.delegate = self
default:
fatalError("Unexpected segue: `\(self)` -> `\(segue.destination)`")
}
}
private func presentDetails(for item: ItemModel) {
let viewController = DetailsViewController.makeWithStoryboard()
viewController.delegate = self
viewController.model = item
present(viewController, animated: true, completion: nil)
}
private func dynamicCast<T>(_ object: Any, as: T.Type) -> T? {
return object as? T
}
public extension UIViewController {
public static func makeWithStoryboard(_ name: String? = nil, bundle: Bundle? = nil) -> Self {
let name = name ?? String(describing: self).components(separatedBy: ".").last!
let bundle = bundle ?? Bundle(for: self)
guard bundle.url(forResource: name, withExtension: "storyboardc") != nil else {
fatalError("Can't find storyboard named `\(name)` in bundle `\(bundle)`.")
//
// XibView.swift
// XibView
//
// Created by Victor Pavlychko on 1/13/18.
//
import UIKit
@IBDesignable
@victor-pavlychko
victor-pavlychko / GlyphTable.m
Created July 18, 2018 21:12 — forked from kurain/GlyphTable.m
Glyphs Table Lookup
//
// GlyphTable.m
//
// Ryutaro Kurai
//
// Original File Name, Author and Licence.
//
// FontLabelStringDrawing.m
// FontLabel
//