Skip to content

Instantly share code, notes, and snippets.

View bannzai's full-sized avatar
スターください

bannzai bannzai

スターください
View GitHub Profile
[
{
"word": "Asshole",
"kana": "アスホール",
"meaning": "いやな奴(Ass=お尻、Hole=穴)",
"notice": "「うざい野郎」「ろくでなし」"
},
{
"word": "あばずれ",
"kana": "あばずれ",
@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] = [
@bannzai
bannzai / add_print_changes.sh
Created November 17, 2023 01:42
Self._printChanges() を入れたり外したり
#!/bin/zsh
SCRIPT_DIR="$(cd `dirname $0` && pwd -P)"
REPOSITORY_ROOT_DIR="$(cd $SCRIPT_DIR && cd .. && pwd -P)"
find "$REPOSITORY_ROOT_DIR" -name "*.swift" -exec sed -i '' '/let _ = Self._printChanges()/d' {} \;
@bannzai
bannzai / generate_translated_localizable_strings.py
Created October 6, 2023 09:50
generate_translated_localizable_strings.py
import json
import os
import openai
openai.organization = os.environ.get("OPENAI_ORGANIZATION")
openai.api_key = os.environ.get("OPENAI_API_KEY")
langs = ['fr']
@bannzai
bannzai / NavigationControllerApp.swift
Last active August 8, 2023 11:30
NavigationStack
class NavigationController: ObservableObject {
@Published var path: NavigationPath = .init()
var destinations: [UUID: () -> any View] = [:]
func push(id: UUID = .init(), @ViewBuilder destination: @escaping () -> some View) {
destinations[id] = destination
path.append(id)
}
func pop() {
path.removeLast()
import SwiftUI
import AVKit
struct ContentView: View {
@State var soundLabelIsShows = false
var body: some View {
ZStack(alignment: .center) {
Image("kane")
.resizable()
@bannzai
bannzai / search.swift
Last active December 23, 2022 11:55
SwiftUI search with text example
import SwiftUI
import Combine
struct SearchView: View {
@StateObject var observer = SearchTextObserver()
var body: some View {
VStack {
TextField("TextField", text: $observer.searchText)
.onChange(of: observer.throttleText) { text in
print("Call API with \(text)")
struct SearchView: View {
@State var text: String
@FocusState var focused: Bool
@Async<[Item]> var async
var body: some View {
VStack {
TextField("Placeholder", text: $text)
.focused($focused)
.onSubmit {
@bannzai
bannzai / random_emoji.dart
Created November 23, 2022 11:32
Dart#randomEmoji
import 'dart:math';
void main() async {
print(_randomEmoji());
}
String _randomEmoji() {
final emojis = _emojis();
return emojis[Random().nextInt(emojis.length - 1)];
}
@bannzai
bannzai / example.swift
Created September 4, 2021 10:46
Example
import Foundation
struct ToDo : Identifiable, Equatable {
let id: UUID
var title: String
var done: Bool
}
let id = UUID()
let todo = ToDo(id: id, title: "value1", done: false)