Skip to content

Instantly share code, notes, and snippets.

Rules

Attributes

Identifier Enabled by default Supports autocorrection
attributes Disabled No

Attributes should be on their own lines in functions and types, but on the same line as variables and imports.

private func split(_ str: String, _ length: Int) -> [String] {
// based on http://stackoverflow.com/a/38980231/1777634
return stride(from: 0, to: str.characters.count, by: length).map { idx -> String in
let startIndex = str.index(str.startIndex, offsetBy: idx)
let endIndex = str.index(startIndex, offsetBy: length,
limitedBy: str.endIndex) ?? str.endIndex
return str[startIndex..<endIndex]
}
}
2016-10-18 01:30:22.795 xcodebuild[24598:22339737] [MT] IDETestOperationsObserverDebug: (E3BF103D-62D8-4B19-AB0F-7B36F8412BFF) Unable to get debug console for logging target process thread state.
2016-10-18 01:30:22.800 xcodebuild[24598:22339737] Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Canceling tests due to timeout in Checking test manager availability... If you believe this error represents a bug, please attach the log file at /Users/marcelofabri/Westfield/westfieldkit-swift/build/Logs/Test/E14E9D8F-E3BF-4D69-94CC-4679AD569459/Session-DemoTests-2016-10-18_012822-WrjHaN.log" UserInfo={NSLocalizedDescription=Canceling tests due to timeout in Checking test manager availability... If you believe this error represents a bug, please attach the log file at /Users/marcelofabri/Westfield/westfieldkit-swift/build/Logs/Test/E14E9D8F-E3BF-4D69-94CC-4679AD569459/Session-DemoTests-2016-10-18_012822-WrjHaN.log}
2016-10-18 01:30:22.804 xcodebuild[24598:22339743] Connection peer refused channel request for
module Fastlane
module Actions
class AddIconOverlayAction < Action
def self.run(params)
Helper.log.info "Image to overlay on icons: #{params[:overlay_image_path]}"
require 'mini_magick'
appiconset = params[:appiconset_path]
import Foundation
import Quartz
extension Array {
func each(doThis: (element: T) -> Void) {
for e in self {
doThis(element: e)
}
}
}
@marcelofabri
marcelofabri / gist:4153d75e01da89abc8b5
Created January 5, 2015 16:51
Scroll to Open on Mac
defaults write com.apple.dock scroll-to-open -bool TRUE;killall Dock
func sumRecursively(numbers: [Int], _ acc:Int = 0) -> Int {
if let head = numbers.first {
let tail = Array(dropFirst(numbers))
return sumRecursively(tail, head + acc)
} else {
return acc
}
}
let myNumbers = [1,2,3,4,5]
@marcelofabri
marcelofabri / cloudkit.swift
Last active September 7, 2022 09:51
CloudKit User Info
let container = CKContainer.defaultContainer()
container.fetchUserRecordIDWithCompletionHandler { (recordID, error) in
if !error {
println(recordID.recordName)
container.requestApplicationPermission(.PermissionUserDiscoverability) { (status, permissionError) in
if status == CKApplicationPermissionStatus.Granted {
container.discoverUserInfoWithUserRecordID(recordID) { (info, fetchError) in
println("\(info.firstName) \(info.lastName)")
}
}
@marcelofabri
marcelofabri / AVSpeechSynthesizer.m
Last active December 23, 2015 16:49
Exemplo de AVSpeechSynthesizer.
// supondo que o device está em pt já
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"O NSNull é o melhor evento sobre"];
utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;
[synthesizer speakUtterance:utterance];
utterance = [AVSpeechUtterance speechUtteranceWithString:@"i O S"];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;
@marcelofabri
marcelofabri / xopen
Last active July 11, 2016 21:34
Open .xcworkspace file if exists or .xcodeproj otherwise. Useful for CocoaPods users. Found it elsewhere, but I can't find it anymore.
#!/usr/bin/env ruby
require 'shellwords'
proj = Dir['*.xcworkspace'].first
proj = Dir['*.xcodeproj'].first unless proj
if proj
puts "Opening #{proj}"
`open #{proj}`