This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PhotosVC+Tips.swift | |
// Find-3 | |
// | |
// Created by A. Zheng (github.com/aheze) on 10/4/22. | |
// Copyright © 2022 A. Zheng. All rights reserved. | |
// | |
import Popovers | |
import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
static let fadeInDuration = CGFloat(1.1) | |
static let pulseDuration = CGFloat(1.6) | |
static let fadeOutDuration = CGFloat(0.3) | |
static let interval = CGFloat(1.6) | |
@State var isAnimating = false | |
@State var timer = Timer.publish(every: interval, on: .main, in: .common).autoconnect() | |
@State var circlesIDs = [UUID()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Paste this into your terminal: | |
curl https://gist.githubusercontent.com/aheze/8e7910c3b48e383bae07d27d4fb9cf57/raw/e5242c41703572936e93fee691e37d23903c9824/starcounter.js -sSL | node - aheze -t 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https'), | |
user = process.argv[2], | |
opts = parseOpts(process.argv.slice(3)) | |
request('/users/' + user, function (res) { | |
if (!res.public_repos) { | |
console.log(res.message) | |
return | |
} | |
var pages = Math.ceil(res.public_repos / 100), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension View { | |
/** | |
Read a view's size. The closure is called whenever the size changes. | |
From https://stackoverflow.com/a/66822461/14351818 | |
*/ | |
func sizeReader(size: @escaping (CGSize) -> Void) -> some View { | |
return background( | |
GeometryReader { geometry in | |
Color.clear | |
.preference(key: ContentSizeReaderPreferenceKey.self, value: geometry.size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import UIKit | |
class ViewModel { | |
var enableSubject = PassthroughSubject<Bool, Never>() /// Similar to NotificationCenter | |
var cancellables = Set<AnyCancellable>() /// Lets you store combine subscribers | |
} | |
class ViewController: UIViewController { | |
let viewModel = ViewModel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension View { | |
/** | |
Read a view's size. The closure is called whenever the size itself changes, or the transaction changes (in the event of a screen rotation.) | |
From https://stackoverflow.com/a/66822461/14351818 | |
*/ | |
func readSize(size: @escaping (CGSize) -> Void) -> some View { | |
return background( | |
GeometryReader { geometry in | |
Color.clear | |
.preference(key: ContentSizeReaderPreferenceKey.self, value: geometry.size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Shared { | |
static func getMatchingLocations(from query: String, region: MKCoordinateRegion) async -> (locations: [MKMapItem], region: MKCoordinateRegion?) { | |
let request = MKLocalSearch.Request() | |
request.naturalLanguageQuery = query | |
request.region = region | |
let search = MKLocalSearch(request: request) | |
return await withCheckedContinuation { continuation in | |
search.start { response, _ in | |
guard let response = response else { |