This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin | |
// first header and last footer when bouncing. This layout subclass fixes that. | |
class StickyLayout: UICollectionViewFlowLayout { | |
override init() { | |
super.init() | |
self.sectionFootersPinToVisibleBounds = true | |
self.sectionHeadersPinToVisibleBounds = true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public struct Unit: Codable, Equatable { | |
init() {} | |
public init(from decoder: Decoder) {} | |
public func encode(to encoder: Encoder) throws {} | |
public static func ==(lhs: Self, rhs: Self) -> Bool { | |
return true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol Stylish: class { | |
func updateStyle() | |
} | |
public class StyleProxy<S: Stylish>: NSObject { | |
fileprivate override init() { } | |
} | |
private class StyleProxyView<S: Stylish>: UIView { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Instead of using enum it's possible to use RawRepresentable struct that will give you support for "unsupported" values, | |
but will cost you excastive switches (you'll alwyas have to handle default case, which will stand for those "unsupported" values) | |
It's defenetely more code than if using optional, but might be better if it comes to unwrapping this value everywhere. | |
*/ | |
//enum System: String, Decodable { | |
// case ios, macos, tvos, watchos | |
//} | |
struct System: RawRepresentable, Decodable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIVisualEffectView { | |
private var filterLayer: CALayer? { | |
return layer.sublayers?.first | |
} | |
private var blurFilter: NSObject? { | |
return filterLayer? | |
.filters?.flatMap({ $0 as? NSObject }) | |
.first(where: { $0.value(forKey: "name") as? String == "gaussianBlur" }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stringify(@StringBuilder _ value: () -> Stringified) { | |
print(value().value) | |
} | |
struct Stringified { | |
let value: String | |
init(_ value: String) { | |
self.value = "stringified " + value | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/sh | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
FILES=($(git ls-files -m | grep ".*\.swift$" | grep -v ".*R.generated.swift$")) | |
if [[ ${FILES[@]} ]]; then | |
export "SCRIPT_INPUT_FILE_COUNT"="${#FILES[@]}" | |
for i in "${!FILES[@]}"; do | |
export "SCRIPT_INPUT_FILE_$i"="${FILES[$i]}" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
let factory: ()->() | |
var closure: ((b: B)->())? | |
init(factory: ()->()) { | |
self.factory = factory | |
} | |
deinit { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: | |
# chmod 755 create_xcode_snippets.rb | |
# ./create_xcode_snippets.rb --project_path "path-to-project-file.xcodeproj" | |
require 'xcodeproj' | |
$project_path = File.expand_path(ARGV.find.with_index { |item, index| ARGV[index - 1] == "--project_path" }) | |
$snippets_path = File.expand_path("~/Library/Developer/Xcode/UserData/CodeSnippets/") | |
$snippet_prefix = "STEP-" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmbededTableView: UITableView { | |
override func intrinsicContentSize() -> CGSize { | |
layoutIfNeeded() | |
return CGSizeMake(UIViewNoIntrinsicMetric, self.contentSize.height) | |
} | |
override func reloadData() { | |
super.reloadData() | |
invalidateIntrinsicContentSize() |
NewerOlder