Skip to content

Instantly share code, notes, and snippets.

View kkebo's full-sized avatar
📱
Using iPad Pro 13” (M4)

Kenta Kubo kkebo

📱
Using iPad Pro 13” (M4)
View GitHub Profile
@kkebo
kkebo / ContentView.swift
Last active May 7, 2025 04:30
Implement scene understanding and visualize meshes with `RealityView`
import RealityKit
import SwiftUI
@MainActor
final class MySystem: System {
// After turning on scene-understanding options, RealityKit automatically generates entities representing real-world geometry with a SceneUnderstandingComponent.
// https://developer.apple.com/documentation/realitykit/realitykit-scene-understanding#Use-scene-reconstruction-in-iOS-and-macOS
private static let query = EntityQuery(where: .has(SceneUnderstandingComponent.self) && .has(ModelComponent.self))
private static let debugMaterial: UnlitMaterial = {
var material = UnlitMaterial(color: .green)
@kkebo
kkebo / build-corelibs-foundation.sh
Last active April 5, 2025 16:31
swift-corelibs-foundation を wasm32-unknown-wasi 向けにビルドするためのスクリプト
#!/bin/bash
set -ex
# 元ファイル: https://github.com/swiftwasm/swiftwasm-build/blob/main/schemes/main/build/build-foundation.sh
# swiftly でツールチェーンをインストール
# swift sdk install で Wasm の Swift SDK をインストール
# swift-collections, swift-foundation, swift-foundation-icu は最新の main ブランチをあらかじめクローンしておく
# libxml2 は https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz からダウンロード
DESTINATION_TOOLCHAIN="$HOME/.swiftpm/swift-sdks/swift-wasm-DEVELOPMENT-SNAPSHOT-2025-03-28-a-wasm32-unknown-wasi.artifactbundle/DEVELOPMENT-SNAPSHOT-2025-03-28-a-wasm32-unknown-wasi/wasm32-unknown-wasi/swift.xctoolchain"
@kkebo
kkebo / config.json
Last active November 22, 2024 05:55
swiftly on macOS
{
"installedToolchains" : [],
"platform" : {
"namePretty" : "macOS",
"architecture" : null,
"name" : "xcode",
"nameFull" : "osx"
}
}
import Foundation
let titles = ["lipsum", "lipsum-zh", "medium-fragment", "small-fragment", "tiny-fragment", "strong"]
let html5everResults = "14330 7331.2 31141 3033.7 300.56 18179" // ns
let zyphyResults = "14000 1619 44000 4628 506 20000" // ns
let howSlowers = zip(
html5everResults.split(separator: " ").map { Double($0)! },
zyphyResults.split(separator: " ").map { Double($0)! }
)
@kkebo
kkebo / ContentView.swift
Last active October 24, 2023 15:13
SwiftUI のプレビュー上でユニットテストを実行する Proof of Concept (ContentView のテストをしたい場合)
import SwiftUI
struct ContentView: View {
@State var hoge = 0
@Environment(\.testCaseNumber) private var testCaseNumber
func change() {
hoge = 3
}
@kkebo
kkebo / main.js
Last active November 13, 2022 10:36
@wasmer/[email protected] で swift-format.wasm のリリースビルドバイナリが実行できない再現コード
const fs = require('fs-extra')
const { WASI } = require('@wasmer/wasi')
const wasiBindings = require('@wasmer/wasi/lib/bindings/node')
const { lowerI64Imports } = require("@wasmer/wasm-transformer")
const wasi = new WASI({
args: ['swift-format', '--version'],
env: {},
bindings: wasiBindings.default,
preopens: {'.': '.'}
@kkebo
kkebo / crash.swift
Last active October 12, 2022 16:45
Xcode Previews 上でプレビューのプロセスがクラッシュするコード (実機だと問題なし) (macOS 12.3 & Xcode 13.3 や iPadOS 15.4 & Swift Playgrounds 4.0.2 で再現することを確認) (Swift 5.7 で修正)
import SwiftUI
// 再現する型: URL, URLError, UUID, Date, Measurement, Locale, some SwiftUI.View
// 再現しない型: String, [Int], [String: Int], some StringProtocol, DispatchQueue, Bundle, Data, DateFormatter, URLSession, JSONEncoder, NSNumber, CGFloat, Decimal, SwiftUI.Text
func foo() async -> URL {
.init(fileURLWithPath: "/")
}
struct ContentView: View {
@kkebo
kkebo / ssh.plist
Last active September 25, 2022 11:16
Plist file for LaunchAgents when OpenSSH is installed via Homebrew (for macOS 13 aarch64)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>com.openssh.sshd.homebrew</string>
<key>Program</key>
<string>/opt/homebrew/sbin/sshd</string>
@kkebo
kkebo / arm64-apple-ios.swiftinterface.swift
Created May 22, 2022 10:32
PackgeDescription in Swift Playgrounds 4.1
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
// swift-module-flags: -target arm64-apple-ios14.7 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -package-description-version 999.0 -module-name PackageDescription
// swift-module-flags-ignorable: -user-module-version 15
import Foundation
import Swift
public struct BuildConfiguration : Swift.Encodable {
public static let debug: PackageDescription.BuildConfiguration
public static let release: PackageDescription.BuildConfiguration
public func encode(to encoder: Swift.Encoder) throws