Skip to content

Instantly share code, notes, and snippets.

@dasdom
dasdom / navigationProblem.swift
Last active January 1, 2025 02:45
SwiftUI identity problem
import SwiftUI
struct CoverWithBoolView: View {
@State var presentCover: Bool = false
var body: some View {
GeometryReader { proxy in
ZStack {
if proxy.size.height > proxy.size.width {
Color.gray
@Jeehut
Jeehut / .editorconfig
Last active December 6, 2024 16:38
This file should be added to every SwiftPM project to ensure Xcode 16+ has the same indentation settings for everyone.
# EditorConfig is awesome: https://editorconfig.org
root = true
[*]
indent_style = space
tab_width = 8
indent_size = 4
end_of_line = lf
@ynagatomo
ynagatomo / ContentView.swift
Created November 25, 2023 06:58
Custom Debug Window in visionOS
//
// ContentView.swift
// DebugWindow
//
// Created by Yasuhito Nagatomo on 2023/11/25.
//
import SwiftUI
import RealityKit
import RealityKitContent
@akirayou
akirayou / DNG.py
Last active February 18, 2025 19:41
# -*- coding: utf-8 -*-
"""
Created on Sun May 9 20:45:45 2021
@author: youak
"""
import glob
files=glob.glob("*.DNG")
is_rig_cam=True #meshroom では depth推定できないような配置のrigカメラは逆効果っぽい(dence画像作成時にコケる)
@khanlou
khanlou / A - Usage.swift
Last active July 14, 2024 20:25
This ScrollView has a modifier called `onScroll`, which is updated when scrolls occur.
struct ContentView: View {
@State var scrollOffset: CGPoint = .zero
var body: some View {
ObservableScrollView {
Text("Hello, world!")
.foregroundColor(self.scrollOffset.y == 0 ? .blue : .red)
}
.onScroll { self.scrollOffset = $0 }
@mattt
mattt / UIViewControllerPreview.swift
Last active December 3, 2024 07:42
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@bwhiteley
bwhiteley / HostingView.swift
Last active November 28, 2024 11:22
Host SwiftUI in a UIView
import Foundation
import SwiftUI
#if os(macOS)
public typealias PlatformViewType = NSView
#elseif !os(watchOS)
import UIKit
public typealias PlatformViewType = UIView
#endif
#if !os(watchOS)
@AntipodeStudiosDev
AntipodeStudiosDev / AddColliders.cs
Created April 30, 2019 03:51
Unity3D Add Colliders To Terrain Details, Mouse Click To Remove Terrain Details
using UnityEngine;
public class AddColliders : MonoBehaviour
{
public Terrain terrain;
private TreeInstance[] _originalTrees;
void Start()
{
@st4rdog
st4rdog / TreeReplacerS.cs
Created March 14, 2019 06:38
Replaces trees on a terrain with prefab.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
// Replaces Unity terrain trees with prefab GameObject.
// http://answers.unity3d.com/questions/723266/converting-all-terrain-trees-to-gameobjects.html
[ExecuteInEditMode]
public class TreeReplacerS : EditorWindow {