Skip to content

Instantly share code, notes, and snippets.

#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
@twinstae
twinstae / coding-is-fun-question-mark.md
Last active April 18, 2024 04:23
코딩은 재미 있나요?

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

요약

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

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

@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 April 19, 2024 20:01
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 March 22, 2024 10:03
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 */ }