Skip to content

Instantly share code, notes, and snippets.

#include <metal_stdlib>
using namespace metal;
namespace JuliaSet {
/// HSV -> RGB
half3 hsv2rgb(half3 c) {
half3 rgb = clamp(abs(fmod(c.x * 6.0 + half3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
return c.z * mix(half3(1.0), rgb, c.y);
}
import SwiftUI
struct SqureFlowView: View {
@StateObject private var holder = SquresHolder()
var body: some View {
TimelineView(.animation) { timeline in
Canvas { context, size in
holder.update(at: timeline.date, in: size)
for item in holder.squre {
#include <metal_stdlib>
using namespace metal;
namespace SmoothMin2d {
float smoothMin(float x1, float x2, float k) {
float h = clamp(0.5 - 0.5 * (x2 - x1) / k, 0.0, 1.0);
return mix(x1, x2, h) - k * h * (1.0 - h);
}
float circleSDF(float2 point, float2 center, float radius) {
@sebjvidal
sebjvidal / ViewController.swift
Created April 30, 2024 15:50
Apple Journal Calendar UI Demo
//
// ViewController.swift
// Journal-Calendar-Demo
//
// Created by Seb Vidal on 30/04/2024.
//
import UIKit
class ViewController: UIViewController {
import SwiftUI
struct LoadingView: View {
@State var theta: Double = 0
let radius: Double = 60
var body: some View {
ZStack {
ForEach(0..<8) { index in
let offset = ((2 * .pi) * Double(index)) / 8
@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 April 12, 2025 11:59
swift-list-features: List Swift compiler upcoming and experimental feature flags. · swift-has-feature: Check if a given compiler knows a specific feature flag, and whether it's an upcoming or experimental flag.
#!/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) {