Skip to content

Instantly share code, notes, and snippets.

View darrarski's full-sized avatar
:octocat:
🍏🦕

Dariusz Rybicki darrarski

:octocat:
🍏🦕
View GitHub Profile
@darrarski
darrarski / uncrustify.cfg
Last active January 4, 2016 05:49
Uncrustify configuration for Objective-C
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment
@darrarski
darrarski / keybase.md
Last active September 13, 2019 12:31
Keybase proof

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 April 29, 2015 19:33
Fastlane.tools action that creates and signs iOS app build
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 November 19, 2015 15:59
Swift Failable Initializer
import Foundation
class User {
let name: String
init(name: String) {
self.name = name
}
@darrarski
darrarski / SystemIdleTime.m
Last active March 30, 2021 07:05
Get Mac OS X system idle time in Swift or Objective-C
//
// 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 June 9, 2016 17:58
Objective-C ArrayMapper
#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
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,
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 July 22, 2024 06:14
UIVisualEffectView subclass that allows to customise effect intensity
// MIT License
//
// Copyright (c) 2017 Dariusz Rybicki Darrarski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@darrarski
darrarski / RxSwift_Observable_RetryCountWhen.swift
Last active February 19, 2020 11:43
RxSwift Observable Retry When with Count
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)
}
}