Skip to content

Instantly share code, notes, and snippets.

View uhooi's full-sized avatar
🟢

uhooi

🟢
View GitHub Profile
@bannzai
bannzai / CarouselView.swift
Last active January 16, 2024 14:32
CarouselView.swift
import SwiftUI
struct Item: Identifiable {
let id = UUID()
var text = ""
var color: Color = .clear
}
struct CarouselView: View {
var items: [Item] = [
import SwiftUI
struct ContentView: View {
@State private var initOffset: CGFloat = .zero
@State private var offset: CGFloat = .zero
@State private var closeButtonYPosition: CGFloat = .zero
let headerHeight: CGFloat = 300
var body: some View {
@kntkymt
kntkymt / ViewBuilderTest.swift
Last active October 27, 2023 06:57
ViewBuilderとifあれこれ
import SwiftUI
struct CounterView: View {
@State var counter = 0
var body: some View {
Button {
counter += 1
} label: {
Text(counter.description)
@niw
niw / main.swift
Created July 12, 2023 04:15
Tiny SExpr Interpretor
import Foundation
extension String: Error {}
// MARK: - Evaluation
enum Atom {
case symbol(String)
case number(Double)
}
@YusukeHosonuma
YusukeHosonuma / goodbye_swiftgen_localize.rb
Created May 23, 2023 01:30
Goodbye Localizable.strings with SwiftGen - SwiftGen によるローカライズを剥がすスクリプト
# -----------------------------------------------------------------------------
# SwiftGen によるローカライズを剥がすスクリプト。
# -----------------------------------------------------------------------------
class String
# シンボル変換
def symbol
# e.g.
# - OK → Ok
# - FAQ → Faq
if vim.api.orig == nil then
vim.api.orig = {}
for name, func in pairs(vim.api) do
vim.api.orig[name] = func
end
local default_win_config = {
border = "single",
}
@d-date
d-date / BundleCurrent.swift
Created April 22, 2023 09:10
Workaround for previewing SwiftPM resources
// Workaround for Bundle resource when running on Xcode previews
// https://forums.swift.org/t/xcode-previews-swiftpm-resources-xcpreviewagent-crashed/51680/10
// https://developer.apple.com/forums/thread/664295?answerId=673644022#673644022
// https://gist.github.com/ctreffs/ad9d23e08d586cf75e4d1c3bb1b1061f
import class Foundation.Bundle
import class Foundation.ProcessInfo
private class BundleFinder {}
@treastrain
treastrain / FormatStyle.md
Created March 26, 2023 17:37
Swift Foundation's `FormatStyle`

in Swift, use formatted methods directly on the types you want to format, optionally using FormatStyle and its subtypes to customize formatter output. This approach supports dates, integers, floating-point numbers, measurements, sequences, and person name components. Foundation caches identically-configured formatter instances internally, allowing you to focus on your app’s formatting needs.

Data Formatting | Apple Developer Documentation https://developer.apple.com/documentation/foundation/data_formatting

Numbers and Currency

@tamaclaw
tamaclaw / 登壇資料チェックリスト.md
Created December 23, 2022 03:01
登壇資料をつくる際に、聞き手の満足度をあげるための構成の組み方の工夫などをまとめたチェックリストです。

登壇資料チェックリスト

こちらは登壇資料をひととおり作成した後に見ていただきたい資料です。

「登壇見たけど、わかりづらくて、よく分からなかった」を少しでも減らし、登壇者のこだわりを参加者のみなさまに伝えやすくするため、こちらのチェックリストをご確認ください。

登壇資料の Bad Case

まずは「わかりづらさ」をなるべく洗い出して対応し、 聞き手にとって「わかりづらい」セッションでは無い 、ということを最低限目指してもらえると嬉しいです。

レビューアーの皆さんも「わかりづらさ」の対応をするサポートを中心にお願いします。

@YusukeHosonuma
YusukeHosonuma / ForEachIndex.swift
Created December 4, 2022 03:31
ForEachIndex (with Algorithms)
import SwiftUI
import Algorithms
struct ForEachIndex<Data: RandomAccessCollection, ID: Hashable, Content: View>: View {
typealias Element = IndexedCollection<Data>.Element
private var data: Data
private var id: KeyPath<Element, ID>
@ViewBuilder private var content: (Element) -> Content