Skip to content

Instantly share code, notes, and snippets.

View iSapozhnik's full-sized avatar
🎯
Focusing

Sapozhnik Ivan iSapozhnik

🎯
Focusing
View GitHub Profile
@iSapozhnik
iSapozhnik / UIView+Nib.swift
Last active June 29, 2016 20:42
UIView loading from Nib
//
// UIView+Nib.swift
// Pods
//
// Created by Sapozhnik Ivan on 29.06.16.
//
//
import Foundation
#!/bin/bash
set -e
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${THIS_SCRIPT_DIR}/.."
# Check if there's something uncommitted (don't release if there are files
# not yet committed)
set +e
@iSapozhnik
iSapozhnik / UIView+Nib.swift
Created June 30, 2016 18:53
[Swift] UIView loaded from Xib
protocol UIViewLoading {}
extension UIView : UIViewLoading {}
extension UIViewLoading where Self : UIView {
static func loadFromNib() -> Self {
let nibName = "\(self)".characters.split{$0 == "."}.map(String.init).last!
let bundle = NSBundle(forClass: self)
let nib = UINib(nibName: nibName, bundle: bundle)
return nib.instantiateWithOwner(self, options: nil).first as! Self
@iSapozhnik
iSapozhnik / gist:5a08b827e5f2ca0c59c9f6d31f1ebc6a
Created July 8, 2016 22:16 — forked from steipete/gist:1175357
Easy [fade] animation for UIImageView.image
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
selected_ = selected;
if (animated) {
CATransition *transition = [CATransition animation];
transition.duration = 0.25f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.selectionImageView.layer addAnimation:transition forKey:nil];
}
//
// APIService.swift
//
// Created by Sapozhnik Ivan on 10.06.16.
// Copyright © 2016 Sapozhnik Ivan. All rights reserved.
//
import Foundation
import Alamofire
import AlamofireObjectMapper
@iSapozhnik
iSapozhnik / GenericTableView.swift
Created April 21, 2017 15:01
Generic UITableView
protocol Reusable: class {
static var reuseIdentifier: String { get }
static var nib: UINib? { get }
}
extension Reusable {
static var reuseIdentifier: String { return String(describing: self) }
static var nib: UINib? { return nil }
@iSapozhnik
iSapozhnik / README.md
Created June 18, 2017 09:41 — forked from melekes/README.md
Test coverage Dashing widget

Test coverage

Test coverage

Description

Dashing widget to display test coverage.

The widget is based on JenkinsBuild, which shows you a completion percentage while Jenkins builds the project and zero in other cases. Actually, if you think about it, build takes only a small amount of time (of course, if your project is not building for half an hour). So we decided to find a more reasonable use of this state and show percentage of test coverage.

@iSapozhnik
iSapozhnik / NSRangeExtension.swift
Last active November 13, 2018 17:03
Substring of a string without taking into account of some characters
import Foundation
extension NSRange {
static func rangeOf(text: String, contains searchKey: String, with filterCharacters: [Character]?) -> NSRange {
var filter = "[ ]{0,1}("
filterCharacters?.forEach { filterCharacter in
filter += "\\" + String(filterCharacter)
if let lastCharacter = filterCharacters?.last, lastCharacter != filterCharacter {
filter += "|"
@iSapozhnik
iSapozhnik / Pattern.swift
Created November 24, 2018 17:20
Haptico pattern with duration parser
import Foundation
class Impact {
private let duration: Int
init(with string: String) {
let result = string.replacingOccurrences( of:"[Oo.()]{1,}", with: "", options: .regularExpression)
self.duration = Int(result)!
}
var description: String {
protocol Injectable {
associatedtype T
func inject(_ parameters: T)
}