Skip to content

Instantly share code, notes, and snippets.

View iSapozhnik's full-sized avatar
🎯
Focusing

Ivan Sapozhnik iSapozhnik

🎯
Focusing
View GitHub Profile
#!/bin/bash
createImagesets() {
for d in *; do
if [ -d $d ] ; then
(cd $d; createImagesets)
fi
if [ -f $d ] ; then
a=${d%@2x.*};
dirname=$a".imageset";
mkdir $dirname;
@iSapozhnik
iSapozhnik / UIImage+Blur.swift
Created April 3, 2019 13:35
Screenshot and Blur
private func screenshot() -> UIImage? {
let format = UIGraphicsImageRendererFormat()
format.scale = UIScreen.main.scale
format.opaque = false
let renderer = UIGraphicsImageRenderer(bounds: layer.bounds, format: format)
return renderer.image { _ in
self.drawHierarchy(in: bounds, afterScreenUpdates: false)
}
}
@iSapozhnik
iSapozhnik / git.sh
Last active February 26, 2019 12:29
Git clean branches
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
protocol Injectable {
associatedtype T
func inject(_ parameters: T)
}
@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 {
@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 / 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 / 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 }
//
// 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 / 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];
}