Skip to content

Instantly share code, notes, and snippets.

View brunogama's full-sized avatar

Bruno da Gama Porciuncula brunogama

View GitHub Profile
@rnapier
rnapier / assertion.swift
Last active August 21, 2020 14:00
AssertionFailure as a type
///
/// Boring setup. See below for the good parts
///
public class Logger {
public static let root = Logger(subsystem: .none, parent: nil)
public let subsystem: Subsystem
public let parent: Logger?
public init(subsystem: Subsystem, parent: Logger? = .root) {
self.subsystem = subsystem
@drrost
drrost / RunSwiftlintOnlyForChangedFiles.sh
Created November 3, 2019 15:48
Runs Swiftlint only for changed files - Xcode run script
# Created by: Rostyslav Druzhchenko
#
# Get current time
#
START_DATE=$(date +"%s")
# Save Swiftlint full path to a local variable
#
SWIFT_LINT=/usr/local/bin/swiftlint
import os.log
func given<A>(_ description: String, block: () throws -> A) rethrows -> A {
os_log("1º Given %{public}@", description)
return try XCTContext.runActivity(named: "Given " + description, block: { _ in try block() })
}
func when<A>(_ description: String, block: () throws -> A) rethrows -> A {
os_log("2º When %{public}@", description)
return try XCTContext.runActivity(named: "When " + description, block: { _ in try block() })
@vinhnx
vinhnx / Fastfile
Last active June 24, 2022 04:43
advanced Fastfile config
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
@reyandrey
reyandrey / CoreDataStack.swift
Last active August 20, 2020 12:59
Core Data stack
import Foundation
import CoreData
public class CoreDataStack {
//MARK: Constants
let kBundleId = "com.qwe.rty.uiop"
let kModelName = "model"
@jboehler
jboehler / README.md
Last active July 3, 2020 17:30
Xcode Behavior Script: Run SwiftLint & SwiftFormat only on modified files (using git to find modified files)

Xcode Behavior Script: Run SwiftLint & SwiftFormat

In Xcode settings you can define your own Behavior Scripts. This script will apply swiftlint and swiftformat to all modified files. The modified files are detected with the help of git.

Xcode Behavoior Script can be assigned with a shortcut so this script can be used to format swift code in xcode with a shortcut. 😎

Dependence:

@johnjreiser
johnjreiser / downloadFakePeople.sh
Created June 12, 2019 16:04
Download Fake People - quick script to grab images from This Person Does Not Exist
#!/bin/bash
MAX=10
if [[ ! -z "$1" ]]; then
MAX=$1
fi
for i in $( seq $MAX ); do
FILE=image${i}.jpg
curl 'https://thispersondoesnotexist.com/image' -H 'authority: thispersondoesnotexist.com' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://thispersondoesnotexist.com/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' --compressed -o $FILE
@discardableResult
public func with<T>(_ value: T, _ builder: (T) -> Void) -> T {
builder(value)
return value
}
@discardableResult
public func with<T>(_ value: T, _ builder: (T) throws -> Void ) rethrows -> T {
try builder(value)
return value
@xRoulanDx
xRoulanDx / timer.js
Last active August 15, 2022 17:25
Bookmarklet для отображения таймера в верхней части страницы
javascript: (function() {
let interval;
let containerElt;
let minElt;
let secElt;
const template =
'<div id="aalexeev-timer" style="background: #434343; padding: 10px; text-align: center; font-size: 40px; font-family: monospace; color: #fff;"><span data-minutes></span>:<span data-seconds></span></div>';
const DEFAULT_MINUTES = 10;
starter();
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red