Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
🍏🦕

Dariusz Rybicki darrarski

:octocat:
🍏🦕
View GitHub Profile
@darrarski
darrarski / build_signed_ipa.rb
Created Apr 29, 2015
Fastlane.tools action that creates and signs iOS app build
View build_signed_ipa.rb
module Fastlane
module Actions
module SharedValues
IPA_OUTPUT_PATH = :IPA_OUTPUT_PATH
end
class BuildSignedIpaAction < Action
def self.run(params)
workspace_path = params[:workspace_path]
scheme = params[:scheme]
@darrarski
darrarski / good.swift
Created Nov 19, 2015
Swift Failable Initializer
View good.swift
import Foundation
class User {
let name: String
init(name: String) {
self.name = name
}
@darrarski
darrarski / uncrustify.cfg
Last active Jan 4, 2016
Uncrustify configuration for Objective-C
View uncrustify.cfg
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment
@darrarski
darrarski / Objective-C_ArrayMapper.m
Last active Jun 9, 2016
Objective-C ArrayMapper
View Objective-C_ArrayMapper.m
#import <Foundation/Foundation.h>
@interface ArrayMapper <InputType, OutputType> : NSObject
- (nonnull NSArray <OutputType> *)map:(nonnull NSArray <InputType> *)inputArray withBlock:(nonnull OutputType _Nonnull (^)(InputType _Nonnull obj))block;
- (nonnull NSArray <OutputType> *)flatMap:(nonnull NSArray <InputType> *)inputArray withBlock:(nonnull OutputType _Nullable (^)(InputType _Nonnull obj))block;
@end
@implementation ArrayMapper
View String+KeystrokeSubsequences.swift
extension String {
/// For "TEST" returns ["T", "TE", "TES", "TEST"]
var keystrokeSubsequences: [String] {
let start = distance(from: startIndex, to: startIndex)
let end = distance(from: startIndex, to: endIndex)
return (start...end).map { index in
let substringEnd = self.index(startIndex, offsetBy: index)
let substring = self[..<substringEnd]
return String(substring)
View UIColor_Hex.swift
import UIKit
extension UIColor {
convenience init?(hexRed red: Int, green: Int, blue: Int, alpha: Int = 255) {
guard red >= 0 && red <= 255 else { return nil }
guard green >= 0 && green <= 255 else { return nil }
guard blue >= 0 && blue <= 255 else { return nil }
self.init(red: CGFloat(red) / 255.0,
@darrarski
darrarski / Swinject_NamedRegistration.swift
Created Jul 18, 2018
NamedRegistration helper for Swinject
View Swinject_NamedRegistration.swift
import Swinject
struct NamedRegistration<Service> {
let service: Service.Type
let name: String
}
extension NamedRegistration {
static func named<Service>(_ name: String) -> NamedRegistration<Service> {
return NamedRegistration<Service>(service: Service.self, name: name)
@darrarski
darrarski / Creating.swift
Created Jul 19, 2018
Swift factory helper
View Creating.swift
protocol Creating {
associatedtype Arguments
associatedtype Service
func create(_ arguments: Arguments) -> Service
}
extension Creating where Arguments == Void {
func create() -> Service {
return create(())
}
@darrarski
darrarski / GradientView.swift
Created Jan 30, 2019
Simple UIKit gradient view
View GradientView.swift
import UIKit
class GradientView: UIView {
init(style: GradientStyle) {
super.init(frame: .zero)
isUserInteractionEnabled = false
gradientLayer.colors = style.colors.map { $0.color.cgColor }
gradientLayer.locations = style.colors.map { NSNumber(value: $0.location) }
gradientLayer.startPoint = style.direction.startPoint
@darrarski
darrarski / UIScrollView+Viewport.swift
Created Jan 30, 2019
UIScrollView viewport frame getter
View UIScrollView+Viewport.swift
import UIKit
extension UIScrollView {
var viewport: CGRect {
return CGRect(
origin: CGPoint(
x: contentOffset.x + adjustedContentInset.left,
y: contentOffset.y + adjustedContentInset.top
),
size: CGSize(