Skip to content

Instantly share code, notes, and snippets.

View brunogama's full-sized avatar
🏠
Working from home

Bruno Gama brunogama

🏠
Working from home
  • Banco Inter
  • Brazil
  • 16:51 (UTC -03:00)
  • X @brunogama
View GitHub Profile
@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
@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
@NikKovIos
NikKovIos / UIButton+ActionBlock.swift
Last active October 1, 2020 18:16
Add the block closure to the UIButton.
/// Block for addTarget
extension UIControl {
public typealias UIControlActionBlock = (_ sender: UIControl) -> Void
public class UIControlClosureWrapper {
let owner: UIControl
let actionBlock: UIControlActionBlock
let event: UIControlEvents
@parrots
parrots / AsyncOperation.swift
Last active May 17, 2021 10:44
A Swifty version of an AsyncOperation which solves two common problems I ran into. (see comment below for issues addressed)
//
// AsyncOperation.swift
// Slopes
//
import Foundation
class AsyncOperation: Operation {
private let stateLock = NSLock()
private var observers: [NSKeyValueObservation] = [NSKeyValueObservation]()