Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
🍏🦕

Dariusz Rybicki darrarski

:octocat:
🍏🦕
View GitHub Profile
@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 / keybase.md
Last active Sep 13, 2019
Keybase proof
View keybase.md

Keybase proof

I hereby claim:

  • I am darrarski on github.
  • I am darrarski (https://keybase.io/darrarski) on keybase.
  • I have a public key whose fingerprint is DBDD 81D8 99ED 9772 2D28 86D0 F759 CCF6 8E12 6988

To claim this, I am signing this object:

@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 / SystemIdleTime.m
Last active Mar 30, 2021
Get Mac OS X system idle time in Swift or Objective-C
View SystemIdleTime.m
//
// Created by Dariusz Rybicki on 17/04/16.
// Copyright © 2016 Darrarski. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
Returns number of seconds since system became idle
@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 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,
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)
@darrarski
darrarski / CustomIntensityVisualEffectView.swift
Last active May 12, 2022
UIVisualEffectView subclass that allows to customise effect intensity
View CustomIntensityVisualEffectView.swift
import UIKit
final class CustomIntensityVisualEffectView: UIVisualEffectView {
/// Create visual effect view with given effect and its intensity
///
/// - Parameters:
/// - effect: visual effect, eg UIBlurEffect(style: .dark)
/// - intensity: custom intensity from 0.0 (no effect) to 1.0 (full effect) using linear scale
init(effect: UIVisualEffect, intensity: CGFloat) {
theEffect = effect
@darrarski
darrarski / RxSwift_Observable_RetryCountWhen.swift
Last active Feb 19, 2020
RxSwift Observable Retry When with Count
View RxSwift_Observable_RetryCountWhen.swift
extension ObservableType {
func retry(_ maxAttemptCount: Int = 1, when: @escaping (Error) -> Observable<Void>) -> Observable<E> {
return retryWhen { errorObservable -> Observable<Void> in
var retries = maxAttemptCount
return errorObservable.flatMap { error -> Observable<Void> in
guard retries > 0 else { return Observable.error(error) }
retries -= 1
return when(error)
}
}