Skip to content

Instantly share code, notes, and snippets.

@MahdiBM
MahdiBM / benchmark-update.yml
Last active September 16, 2024 22:29
Update Benchmark Thresholds
name: update-benchmark-thresholds
on:
workflow_dispatch:
inputs:
# This will have to be an exhastive list of all benchmarks.
# If there is a benchmark name missing, just update this list and push.
benchmark:
type: choice
required: true
@MahdiBM
MahdiBM / benchmark.yml
Last active September 18, 2024 12:51
Using package-benchmark for benchmarking Swift code
name: benchmark
on:
workflow_dispatch:
pull_request: { types: [opened, reopened, synchronize] }
push: { branches: [main] }
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@macshome
macshome / EnvironmentVariables.swift
Created May 2, 2024 12:48
A playground to see different ways to get environment variables in Swift
import Foundation
// A playground to see different ways to get environment variables in Swift
// Foundation is the easiest way using the awesome ProcessInfo class.
// Get all of the environment variables for your running process in a Dictionary.
let foundationEnv = ProcessInfo().environment
print("********** ProcessInfo Environment **********")
@schwa
schwa / SwiftUI for macOS Missing Features.md
Last active January 31, 2024 02:45
SwiftUI for macOS Missing Features

https://mastodon.social/@schwa/111801520286334341

My list:

  • Tap location for contextual menus. A lot of apps need to know exactly where a context menu is being triggered from (e.g. canvas style editors etc).
  • Modifier key observation during button presses/gestures etc.
  • Cursor support
  • Native Undo Manager support (SwiftUI has Environment.undoManager but it just exposes Cocoa's UndoManager which doesn't feel very SwiftUI like).
  • Expanded File Dialog options (e.g. adding buttons to the dialog).
  • The outline variant of List (List(… children: …)) is missing a lot of the flexibility of NSOutlineView (TODO: flesh this out with concrete example).
@arthurschiller
arthurschiller / RealityRendererTest.swift
Last active April 25, 2024 18:59
RealityRenderer Test (visionOS)
//
// RealityRendererView.swift
// RealityRendererTest
//
// Created by Arthur Schiller on 11.01.24.
//
import SwiftUI
import Metal
import MetalKit
@MahdiBM
MahdiBM / vapor+openapi+tasklocals.swift
Last active February 27, 2024 20:14
swift-openapi-vapor + `TaskLocal`s to pass the `Request` to the OpenAPI handler
/// PREREQUISITES:
/// Add https://github.com/pointfreeco/swift-dependencies as a dependency of your target, currently it looks like so:
/// `.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"),`
// MARK: '+DependencyValues.swift'
import Vapor
import Dependencies
extension DependencyValues {
@bgolus
bgolus / PostDepthToWorldPos.shader
Last active October 30, 2023 18:14
Get the world position from the camera depth texture with no external dependencies. Works as a post process or on an transparent object in the scene.
Shader "PostDepthToWorldPos"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
Shader "Pristine Triplanar Grid"
{
Properties
{
[KeywordEnum(World,Object,ObjectAlignedWorld)] _GridSpace ("Grid Space", Float) = 0.0
_GridScale ("Grid Scale", Float) = 1.0
[Toggle(USE_VERTEX_NORMALS)] _UseVertexNormals ("Use Vertex Normals", Float) = 0.0
[Toggle] _ShowOnlyTwo ("Show Only Two Grid Axis", Float) = 0.0
@bgolus
bgolus / PristineRadialGrid.shader
Last active June 12, 2024 18:15
An application of the Pristine Grid technique onto radial grid with atan derivative discontinuity fixes applied. https://bgolus.medium.com/the-best-darn-grid-shader-yet-727f9278b9d8 https://bgolus.medium.com/distinctive-derivative-differences-cce38d36797b
Shader "Pristine Radial Grid"
{
Properties
{
[Toggle] _WorldUV ("Use World Space UV", Float) = 1.0
_GridScale ("Grid Scale", Float) = 1.0
[Toggle] _UseAdaptiveAngularSegments ("Use Adaptive Angular Segment Count", Float) = 0.0
[IntRange] _AngularSegments ("Angular Segments", Range(1,360)) = 4.0
Shader "Pristine Grid"
{
Properties
{
[KeywordEnum(MeshUV, WorldX, WorldY, WorldZ)] _UVMode ("UV Mode", Float) = 2.0
_GridScale ("Grid Scale", Float) = 1.0
_LineWidthX ("Line Width X", Range(0,1.0)) = 0.01
_LineWidthY ("Line Width Y", Range(0,1.0)) = 0.01