Skip to content

Instantly share code, notes, and snippets.

View Kyome22's full-sized avatar
🏠
Working from home

Takuto NAKAMURA (Kyome) Kyome22

🏠
Working from home
View GitHub Profile
@Kyome22
Kyome22 / SmartBattery.swift
Last active July 29, 2026 05:35
Check AppleSmartBattery
import Foundation
import IOKit
import IOKit.ps
struct SmartBattery {
private func fetchIOServiceProperties(name: String) -> [String: AnyObject]? {
// Open Connection
let service = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceNameMatching(name))
guard service != IO_OBJECT_NULL else {
return nil
@Kyome22
Kyome22 / CLAUDE.md
Created July 18, 2026 04:30
Build system priority for Apple platform projects

Global preferences and rules

Build system priority for Apple platform projects

For any Xcode project or Swift Package Manager package, use this order — pick the first option that fits the situation, do not skip down the list.

  1. Xcode MCP Tools — use these when Xcode has the project open. They reuse the running Xcode's build state (no duplicate DerivedData / build caches piling up), and open the door to workflows the CLI cannot reach — running screenshot / snapshot tests through the running IDE, driving simulators the user is already using, etc.

  2. xcodebuild — for CLI builds and tests. Compiles bundled resources correctly: .xcstrings string catalogs become per-locale .strings inside the bundle, .xcassets are compiled, etc. Use this when Xcode is not open or when a headless build is needed.

@Kyome22
Kyome22 / ContentView.swift
Created January 22, 2026 03:06
Strange Animation with contentMargins(.training)
import SwiftUI
public struct ContentView: View {
@State var items = [Item]()
public init() {}
public var body: some View {
HStack {
Button {
@Kyome22
Kyome22 / AppDelegate.swift
Created October 18, 2025 14:36
Additional Buttons for macOS Window
import Cocoa
import SwiftUI
struct CustomButton: View {
var fillColor: Color
var bezelColor: Color
var symbol: String
var body: some View {
Button {
@Kyome22
Kyome22 / TestCode.swift
Created August 24, 2025 04:33
Battery Health
import Foundation
import IOKit.ps
@main
struct TestCode {
static func main() async throws {
let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue()
let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as? [CFDictionary]
guard let psList else {
return
import AppKit
struct Hoge {
@discardableResult
static func doSomething(handler block: @escaping () -> Void) -> Any? { nil }
}
actor SomeService {
func update() {}
@Kyome22
Kyome22 / CannotFinishXCTest.swift
Last active March 15, 2023 04:41
XCTestが終わらなくなるやつ
import Foundation
import Combine
protocol NumberRepository: AnyObject {
var numberPublisher: AnyPublisher<Int, Never> { get }
}
class Sample: ObservableObject {
@Published var number: Int = 0
private var cancellables = Set<AnyCancellable>()
@Kyome22
Kyome22 / SwiftTree.swift
Last active July 29, 2026 05:17
Print an object like the tree format.
import Foundation
struct SwiftTree {
enum RuledLine {
static let root = "."
static let stem = "│  "
static let branch = "├──"
static let lastBranch = "└──"
static let space = "   "
}
@Kyome22
Kyome22 / XCTContext+Extension.swift
Last active April 16, 2022 07:45
XCTContext.runActivities(setUp:tearDown:blocks:)
//
// XCTContext+Extension.swift
// TestEachTests
//
// Created by ky0me22 on 2022/04/07.
//
import XCTest
extension XCTContext {
@Kyome22
Kyome22 / Learning_Chords.md
Created November 14, 2021 06:50
ピアノのコード学習のメモ

ピアノのコード覚え方

音階の基本

ド レ ミ ファ ソ ラ シ
C D E F G A B

ルートは 12 種類ある