Skip to content

Instantly share code, notes, and snippets.

View polqf's full-sized avatar

Pol Quintana polqf

View GitHub Profile
@polqf
polqf / Collection+SafeSubscript.swift
Created December 4, 2020 17:43
Returns the element at the specified index if it is within bounds, otherwise nil.
extension Collection {
/// Returns the element at the specified index if it is within bounds, otherwise nil.
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
@polqf
polqf / report_time.rb
Last active October 15, 2020 09:04
Based on @PaulTaykalo's xcode-time-tracker I created a small script to have live Xcode build time results on a console
# This script will output the accumulated time you've spend building projects on Xcode within the current day.
#
# Output looks like:
# *********
# You've spent 27min 24s building <your-project-name>.xcworkspace today
#
#
# To use it:
# 1. Follow the installation process from https://github.com/PaulTaykalo/xcode-time-tracker
# 2. Copy this script to `~/.timecheck` folder.
@polqf
polqf / Compile on iOS 11 Device using Xcode 8.3
Last active October 7, 2021 08:56
Compile on iOS 11 Device using Xcode 8.3
cp -r /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11.0\ \(15A5278f\) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11.0\ \(15A5278f\)
# Make sure you have Xcode 9 Beta 1 in /Applications/Xcode-beta.app
# Make sure you have Xcode 8.3.X in /Applications/Xcode.app
# Whenever there's a new update on Xcode 9 &/| iOS 11, you'll need to do this again using the new DeviceSupport folder
@polqf
polqf / SourceKitFix.rb
Last active August 26, 2021 16:42
SourceKit Fix
#
# This fix should solve most of the problems with SourceKit (Not only with Swift, also with Obj-C). Such as:
# - Not having autocompletion
# - False errors
#
# This is just a temporal fix. The problem could eventually return.
# If that happens, just re-run this file
#
# The implementation comes from an answer in stackoverflow, which helped me a lot.
#