Skip to content

Instantly share code, notes, and snippets.

@ollieatkinson
ollieatkinson / UIGestureRecognizer.Publisher.swift
Created April 29, 2021 10:48
Combine publisher for UIGestureRecognizer
extension UIView {
func publisher<G>(for gestureRecognizer: G) -> UIGestureRecognizer.Publisher<G> where G: UIGestureRecognizer {
UIGestureRecognizer.Publisher(gestureRecognizer: gestureRecognizer, view: self)
}
}
extension UIGestureRecognizer {
struct Publisher<G>: Combine.Publisher where G: UIGestureRecognizer {
@CJBridges
CJBridges / circleci_command_for_cache_optimization.yml
Last active January 22, 2024 18:56
CircleCI does not support checks for existence of a cache key without restoring the full cache. Save a tiny key in parallel with the cache to allow bailing out faster if the cache already exists. More documentation on the approach and the code I started from (thanks TzookB!) is here: https://tzookb.com/circleci-project-deepdive
commands:
halt_if_cache_exists:
description: Halt a build if a cache already exists, without downloading the entire cache. Match only exact key. Pair with mark_cache_existence.
parameters:
category:
description: friendly name of the sort of cache (e.g. bundle, src)
type: string
key:
description: hash key where underlying data would be stored
@damian-rzeszot
damian-rzeszot / override_app_extensions.sh
Last active April 28, 2023 20:20
override_app_extensions.sh
alias plistbuddy=/usr/libexec/PlistBuddy
alias codesign=/usr/bin/codesign
#
# Bundle identifier
#
set_plist_bundle_identifier() {
local bundle_identifier="$1"
@freak4pc
freak4pc / Combine+WithLatestFrom.swift
Last active February 19, 2024 15:35
withLatestFrom for Apple's Combine
//
// Combine+WithLatestFrom.swift
//
// Created by Shai Mishali on 29/08/2019.
// Copyright © 2019 Shai Mishali. All rights reserved.
//
import Combine
// MARK: - Operator methods
@shaps80
shaps80 / AVPlayer+Scrubbing.swift
Last active April 18, 2024 22:31
Enables smooth frame-by-frame scrubbing (in both directions) – similar to Apple's applications.
public enum Direction {
case forward
case backward
}
internal var player: AVPlayer?
private var isSeekInProgress = false
private var chaseTime = kCMTimeZero
private var preferredFrameRate: Float = 23.98
@dgyesbreghs
dgyesbreghs / FirstWeekDay
Created June 30, 2015 12:29
Get first day of a week with Swift
//: Playground - noun: a place where people can play
import UIKit
let today = NSDate.new()
let gregorian = NSCalendar.currentCalendar()
let weekdayComponetns = gregorian.components(NSCalendarUnit.Weekday, fromDate: today)
let compontentsToSubstract = NSDateComponents.new()
//
// SimpleScrollingStack.swift
// A super-simple demo of a scrolling UIStackView in iOS 9
//
// Created by Paul Hudson on 10/06/2015.
// Learn Swift at www.hackingwithswift.com
// @twostraws
//
import UIKit