Skip to content

Instantly share code, notes, and snippets.

@felginep
felginep / RequiredOptions.rb
Created October 7, 2020 06:28
Create lanes with non optional parameters and raises an error if we try to access a missing value from the `option` hash
class Fastlane::FastFile # from https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/fast_file.rb
# Hash that raises an error when we access a missing value
class RequiredOptions < Hash
def initialize(options, lane)
options.each { |key, value| self[key] = value }
@lane = lane
end
@felginep
felginep / Fastfile.rb
Last active August 10, 2020 14:21
Automatically post a PR comment if a license warning is found
lane :lint_pull_request do |options|
add_license_message(
repository_name: "felginep/my-ios-app",
api_token: ENV["GITHUB_TOKEN"],
issue_number: options[:issue_number]
)
end
@felginep
felginep / comment_github_issue.rb
Created August 7, 2020 10:08
Fastlane action to comment a Github issue / pull request
# heavily inspired from https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/set_github_release.rb
module Fastlane
module Actions
module SharedValues
COMMENT_GITHUB_ISSUE_COMMENT_LINK = :COMMENT_GITHUB_ISSUE_COMMENT_LINK
COMMENT_GITHUB_ISSUE_COMMENT_ID = :COMMENT_GITHUB_ISSUE_COMMENT_ID
COMMENT_GITHUB_ISSUE_COMMENT_JSON = :COMMENT_GITHUB_ISSUE_COMMENT_JSON
end
class CommentGithubIssueAction < Action
import UIKit
struct Action {
let title: String
let style: UIAlertAction.Style
let action: () -> Void
}
extension Action {
static func `default`(_ title: String, action: @escaping () -> Void) -> [Action] {
import UIKit
struct AlertBuilder {
private var style: UIAlertController.Style = .alert
private var title: String?
private var message: String?
private var actions: [UIAlertAction] = []
func style(_ style: UIAlertController.Style) -> AlertBuilder {
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red
import UIKit
import Foundation
func test(named: String,
_ work: (_ assert: @escaping (Bool) -> Void, _ done: @escaping () -> Void) -> Void) {
var testPass = true
var assertCount = 0
let assert: (Bool) -> Void = { value in
assertCount = assertCount + 1
testPass = testPass && value
disabled_rules: # rule identifiers to exclude from running
# not sure
- closure_parameter_position
- unused_closure_parameter
- operator_whitespace # what about defining func ==()
- colon
# - force_cast
# - force_try
# useless
protocol ContentSizable {
func ad_updateContentSize()
}
extension UIView : ContentSizable {
func ad_updateContentSize() {
subviews.forEach { $0.ad_updateContentSize() }
}
}

Xcode Shortcuts

Customized

^& Standard Editor > Show Related Items ^1
Standard Editor > Show Previous History ^2
^⌘É Standard Editor > Show Previous File History ^⌘2
^" Standard Editor > Show Next History ^3
^⌘" Standard Editor > Show Next Files History ^⌘3
^’ Standard Editor > Show Top Level Items ^4