Skip to content

Instantly share code, notes, and snippets.

View BrentMifsud's full-sized avatar

Brent Mifsud BrentMifsud

View GitHub Profile
extension StringProtocol {
subscript(_ offset: Int) -> String.Element {
if offset >= 0 {
self[index(startIndex, offsetBy: offset)]
} else {
self[index(endIndex, offsetBy: offset)]
}
}
@christianselig
christianselig / UIAlertController+Conversion.swift
Created September 3, 2021 18:14
Adding an image to a UIAlertController
extension UIAlertController {
/// Creates a view controller for notifying the user that a conversion is occurring. Accepts a block that is executed upon conversion completion.
static func createConvertingAlertController(onConversionCompletion: @escaping () -> Void) -> UIAlertController {
// The title font corresponds to Dynamic Type style "Headline"
let titleFont = UIFont.preferredFont(forTextStyle: .headline)
let calculatorImageView = UIImageView(image: UIImage(named: "calculator.fill", in: nil, with: UIImage.SymbolConfiguration(font: UIFont.systemFont(ofSize: titleFont.pointSize * 2.0, weight: .semibold))))
let measuringAttributedStringHeight = NSAttributedString(string: "Penguin", attributes: [.font: titleFont]).boundingRect(with: .zero, options: [.usesFontLeading, .usesLineFragmentOrigin], context: nil).height
let desiredOffset = 15.0 + calculatorImageView.bounds.height
let totalNewlinePrefixes = Int((desiredOffset / measuringAttributedStringHeight).
@matijs
matijs / README.md
Last active February 22, 2024 05:35
Solarized Dark profile for macOS Terminal.app

Solarized Dark profile for Terminal.app on macOS High Sierra

Based on the excellent Solarized (Dark) created by Ethan Schoonover. For source code, check the main Solarized repository on GitHub.

Installation

Open and save Solarized Dark.terminal.

Import from the “Profiles” tab in the settings of Terminal.app or just double-click the file after downloading.

@freak4pc
freak4pc / MKMultiPoint+Ext.swift
Last active April 25, 2024 04:38
Get a list of coordinates from a MKPolyline / MKRoute
public extension MKMultiPoint {
var coordinates: [CLLocationCoordinate2D] {
var coords = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid,
count: pointCount)
getCoordinates(&coords, range: NSRange(location: 0, length: pointCount))
return coords
}
}
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR