Skip to content

Instantly share code, notes, and snippets.

View azone's full-sized avatar
👨‍💻
Coding

Yozone Wang azone

👨‍💻
Coding
View GitHub Profile
@swiftui-lab
swiftui-lab / anim-part6.swift
Last active August 25, 2024 17:51
Examples for SwiftUI Blog Post (Advanced SwiftUI Animations - Part 6)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Advanced SwiftUI Animations - Part 6 Examples
// blog article: https://swiftui-lab.com/swiftui-animations-part6
import SwiftUI
struct ContentView: View {
@State var show: Int? = nil
var body: some View {
@HarshilShah
HarshilShah / CycledAnimationTimelineView.swift
Created April 29, 2023 05:17
A SwiftUI view that performs a looping animation in whole cycles. When the animation is disabled, it drives the current loop to completion, and pauses only then
struct CycledAnimationTimelineView<Content: View>: View {
var duration: Double
var isAnimating: Bool
@ViewBuilder var content: (Double) -> Content
@State private var isActuallyAnimating = false
@State private var startDate: Date?
var body: some View {
TimelineView(.animation(paused: !isActuallyAnimating)) { context in
@ole
ole / set-photos-keyboard-shortcuts.sh
Last active May 4, 2024 02:10
Assign a keyboard shortcut to the Export Unmodified Originals menu command in Photos.app on macOS
#!/bin/bash
# Assigns a keyboard shortcut to the Export Unmodified Originals
# menu command in Photos.app on macOS.
# @ = Command
# ^ = Control
# ~ = Option
# $ = Shift
shortcut='@~^e'
@mayoff
mayoff / UnitPoint.angle.swift
Last active July 16, 2023 15:07
point on unit square at a given angle
import SwiftUI
extension UnitPoint {
/// - returns: The point on the perimeter of the unit square that is at angle `angle` relative to the center of the unit square.
init(_ angle: Angle) {
// Inspired by https://math.stackexchange.com/a/4041510/399217
// Also see https://www.desmos.com/calculator/k13553cbgk
let s = sin(angle.radians)
let c = cos(angle.radians)
@UnderscoreDavidSmith
UnderscoreDavidSmith / Sparkle.swift
Created December 20, 2022 16:00
Sparkle Effect in SwiftUI
@available(iOS 15.0, *)
struct TwinkleView:View {
private func position(in proxy: GeometryProxy, sparkle:Sparkle) -> CGPoint {
let radius = min(proxy.size.width, proxy.size.height) / 2.0
let drawnRadius = (radius - 5) * sparkle.position.x
let angle = Double.pi * 2.0 * sparkle.position.y
let x = proxy.size.width * 0.5 + drawnRadius * cos(angle)
let y = proxy.size.height * 0.5 + drawnRadius * sin(angle)
@xqm32
xqm32 / clash-config.yaml
Last active September 11, 2024 17:02
clash config with proxy-providers and rule-providers
##### 使用说明 #####
# 1. 请填写 proxy-providers - subscribe - url 为订阅链接
# 2. 下载 https://github.com/Loyalsoldier/clash-rules/archive/refs/heads/release.zip 并解压至 ./profiles/ruleset 文件夹下
# 3. 若需要自动更新 ruleset, 请编辑 rule-providers-config - type 为 http
##### 参考链接 #####
# 1. clash 样例配置文件
# https://lancellc.gitbook.io/clash/clash-config-file/an-example-configuration-file
# 2. clash 规则集
# https://github.com/Loyalsoldier/clash-rules
@ole
ole / Text+Link.swift
Created May 12, 2022 10:50
Add links in SwiftUI Text views via a custom string interpolation.
import SwiftUI
extension CGPoint {
static func *(lhs: Self, rhs: CGFloat) -> Self {
.init(x: lhs.x * rhs, y: lhs.y * rhs)
}
}
// Idea: https://www.framer.com/showcase/project/lo2Qka8jtPXrjzZaPZdB/
@andrewnk
andrewnk / gist:ecba8448b5009eaa3ae1433c549d881d
Created July 20, 2021 01:01
Resize partition in alpine
# after the virtual disk has already been expanded (e.g. in proxmox)
apk add --no-cache cfdisk e2fsprogs-extra
# choose partition then "Resize" > "Write" (to finalize)
cfdisk
# replace * with partition you are resizing
resize2fs /dev/*
import SwiftUI
// View to split up a string into Text views, split by spaces.
struct ContentText: View {
private var splitText: [String]
let count: Int
init(_ text: String) {
self.splitText = text.split(separator: " ").map { "\($0) " }
if text.hasPrefix(" ") {