Skip to content

Instantly share code, notes, and snippets.

@p-x9
p-x9 / create-xcframework.sh
Last active February 26, 2024 13:33
Create xcframework from Swift Package
set -Ceu
PACKAGE_DIR=$(
cd "$(dirname "$0")/.." || exit 1
pwd
)
cd "${PACKAGE_DIR}" || exit 1
DERIVED_DATA_PATH=".build"
OUTPUT="XCFrameworks"
import SwiftUI
struct ContentView: View {
@State var theta: Double = 0
let radius: Double = 60
let colors: [Color] = [.purple, .red, .yellow, .blue, .green]
var body: some View {
ZStack {
ForEach(Array(colors.enumerated()), id: \.offset) { offset, style in
@ole
ole / swift-has-feature.sh
Last active September 7, 2025 10:12
swift-list-features: List Swift compiler upcoming and experimental feature flags. If you're using Swift 6.2 or later, `swift -print-supported-features` does something very similar, but only for the compiler version you have installed. · swift-has-feature: Check if a given compiler knows a specific feature flag, and whether it's an upcoming or ex…
#!/bin/zsh
# Test if the Swift compiler knows about a particular language feature.
#
# Usage:
#
# swift-has-feature [--swift SWIFT_PATH] [--language-version LANGUAGE_VERSION] FEATURE
#
# The feature should be an upcoming or experimental language feature,
# such as `"StrictConcurrency"` or `"ExistentialAny"`.
@twinstae
twinstae / coding-is-fun-question-mark.md
Last active October 25, 2024 01:14
코딩은 재미 있나요?

안녕하세요. 탐토입니다. 오늘은 코딩이 어떻게 하면 재미있어질 수 있는지에 대해 이야기해보려 해요.

요약

  • 자전거 배달부로 아기를 돌보는 분들에게 기저귀와 분유 배달하는 것도 보람찬 일이었다.
  • 코딩으로 가치있는 문제를 해결하는 것도 힘들지만 즐거웠으며, 보람찬 일을 하는 건 노동자의 권리다.
  • 천재 슈퍼 개발자가 아니면 무시 받아 마땅하고 해고와 연봉 삭감의 사유라는 것은 자본가들의 가스라이팅일 뿐이다.
  • 누구나 자기의 속도로 하나 둘 해나가면 성장하고 성취하고 즐거움을 찾을 수 있다.
  • 쓸모 없지만 재미있는 일을 하다보면 쓸모도 생기는 것이지. 쓸모에 집착하면 우울해집니다.

저는 부럽다는 말을 많이 듣습니다. 물론 잘 알지도 못하면서 아는 척 한다고 욕도 먹습니다만. 부럽다는 레파토리 중에 하나는 "토끼 님은 코딩이 재미있어 보인다"는 것입니다.

@el-hoshino
el-hoshino / AssociativeComparisonPrecedence.swift
Last active February 5, 2024 22:40
AssociativeComparison
precedencegroup AssociativeComparisonPrecedence {
associativity: left
higherThan: ComparisonPrecedence
lowerThan: NilCoalescingPrecedence
}
infix operator <: AssociativeComparisonPrecedence
infix operator <=: AssociativeComparisonPrecedence
public func < <V: Comparable>(lhs: V, rhs: V) -> (Bool, V) {
@unixzii
unixzii / ContentView.swift
Last active March 30, 2024 08:36
GPU particle system using Metal.
import SwiftUI
struct SmashableView: NSViewRepresentable {
typealias NSViewType = _SmashableNSView
let text: String
class _SmashableNSView: NSView {
@realvjy
realvjy / ChoasLinesShader.metal
Last active September 2, 2025 20:43
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@Alex-Ozun
Alex-Ozun / typestate-tesla-car.swift
Last active September 8, 2025 06:09
Typestate in Swift
enum Parked {}
enum Driving {}
enum Gaming {}
private class EngineSystem {
static var shared = EngineSystem()
private init() {}
func start() {/**/}
func accelerate() { /* Uses gas pedal input to accelerate the real car */ }
@unixzii
unixzii / WeatherView.swift
Created November 7, 2023 13:21
A demo of implementing iOS Weather card in SwiftUI.
import SwiftUI
struct HeaderView: View {
var body: some View {
HStack {
Image(systemName: "info.circle.fill")
.resizable()
.frame(width: 12, height: 12)
Text("Section Header")
.font(.system(size: 13))
@timsneath
timsneath / dragcard.swift
Created October 17, 2023 04:46
Small sample of a draggable card object in SwiftUI
// Adapted from Hacking with SwiftUI, credit to Paul Hudson (@twostraws).
// https://www.hackingwithswift.com/books/ios-swiftui/animating-gestures
import SwiftUI
struct ContentView: View {
@State private var dragAmount = CGSize.zero
var body: some View {
RoundedRectangle(cornerRadius: 10)