Skip to content

Instantly share code, notes, and snippets.

View Viveron's full-sized avatar
🔨

Viktor Shabanov Viveron

🔨
  • London, UK
  • 09:20 (UTC +01:00)
View GitHub Profile
@Viveron
Viveron / NSString+Hash.h
Created August 10, 2018 08:17
NSString md5 hash category
#import <Foundation/Foundation.h>
@interface NSString (Hash)
- (NSString *)md5;
+ (NSString *)stringWithHash:(unsigned char *)hash
digestLength:(int32_t)digestLength;
@end
@Viveron
Viveron / CAGradientLayer+Direction.swift
Created August 6, 2018 13:15
Gradient direction for simplifying gradient draw
import UIKit
extension CAGradientLayer {
enum Direction {
case left
case top
case right
case bottom
case custom(start: CGPoint, end: CGPoint)
@Viveron
Viveron / Localized.swift
Created July 23, 2018 15:49
Common type for aggregation all UI strings, that should be localized
import Foundation
typealias Localized = String
extension Localized {
func localize() -> String {
return NSLocalizedString(self, comment: "")
}
@Viveron
Viveron / FontFamily+Roboto.swift
Last active July 23, 2018 13:54
Application's fonts protocol for easy and convenient fonts makeup use
import Foundation
enum Roboto: String, FontFamily {
case thin = "Roboto-Thin"
case bold = "Roboto-Bold"
case light = "Roboto-Light"
case medium = "Roboto-Medium"
case regular = "Roboto-Regular"
}
@Viveron
Viveron / UIColor+Hex.swift
Last active July 23, 2018 13:52
Swift color extension
import Foundation
extension UIColor {
convenience init(hex: Int, alpha: CGFloat? = nil) {
self.init(((hex >> 16) & 0xFF),
((hex >> 8) & 0xFF),
(hex & 0xFF),
alpha)
}
@Viveron
Viveron / xcode_run_script_phase.sh
Last active July 21, 2018 20:05
Build time warnings highlighting in project on Swift
if [ "${CONFIGURATION}" = "Debug" ]; then
TAGS="\/\/ TODO:|\/\/TODO:|\/\/ FIXME:|\/\/FIXME:|\/\/ WARNING:|\/\/WARNING:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/${TAGS}/ warning: \$1/"
fi