Skip to content

Instantly share code, notes, and snippets.

View jasongerard's full-sized avatar
💰
snapping necks and cashing checks

Jason Gerard jasongerard

💰
snapping necks and cashing checks
View GitHub Profile
@ChrisMash
ChrisMash / PlayerTimeView.swift
Created March 10, 2020 19:09
A SwiftUI View to display an AVPlayer's currentTime from PlayerTimeObserver's publisher
import SwiftUI
import AVFoundation
struct PlayerTimeView: View {
let timeObserver: PlayerTimeObserver
@State private var currentTime: TimeInterval = 0
var body: some View {
Text("\(Utility.formatSecondsToHMS(currentTime))")
.onReceive(timeObserver.publisher) { time in
@ChrisMash
ChrisMash / PlayerTimeObserver.swift
Created March 10, 2020 19:06
An observer for AVPlayer's currentTime that publishes it with Combine
import Combine
class PlayerTimeObserver {
let publisher = PassthroughSubject<TimeInterval, Never>()
private var timeObservation: Any?
init(player: AVPlayer) {
// Periodically observe the player's current time, whilst playing
timeObservation = player.addPeriodicTimeObserver(forInterval: CMTime(seconds: 0.5, preferredTimescale: 600), queue: nil) { [weak self] time in
guard let self = self else { return }
@dmitshur
dmitshur / gist:6927554
Last active September 17, 2023 07:35
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.

WARNING: This gist was created in 2013 and targets the legacy GOPATH mode. If you're reading this in 2021 or later, you're likely better served by reading https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.

$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!