Skip to content

Instantly share code, notes, and snippets.

View AkkeyLab's full-sized avatar

Akio Itaya AkkeyLab

View GitHub Profile
@kalupas226
kalupas226 / JapaneseTCA.md
Last active June 19, 2024 05:11
A Japanese translation of The Composable Architecture's README.md

The Composable Architecture

CI Slack

The Composable Architecture (省略すると TCA) は、コンポジション、テスト、開発者にとっての使いやすさを考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用

@satoshun
satoshun / jetpack_compose_keyboard.md
Last active December 18, 2022 13:26
Jetpack Compose キーボード少しめも

LocalSoftwareKeyboardController, FocusRequester の2クラスを使う

キーボードのshow/hide

LocalSoftwareKeyboardControllerを取得して、show/hideメソッドをコールする

@Composable
fun sample() {
 val keyboardController = LocalSoftwareKeyboardController.current
import Combine
import UIKit
public protocol CombineCompatible {}
// MARK: - UIControl
public extension UIControl {
final class Subscription<SubscriberType: Subscriber, Control: UIControl>: Combine.Subscription where SubscriberType.Input == Control {
private var subscriber: SubscriberType?
private let input: Control
@yimajo
yimajo / ContentView.swift
Last active September 6, 2021 09:21
SwiftUIでBindingは参照元の値を変更できるが、Stateは参照元の値を変更できないサンプル。Playgroundで動作する。
import PlaygroundSupport
import SwiftUI
import Combine
class ObservableObject1: ObservableObject {
@Published var name: String = "src"
}
struct ContentView1: View {
@ObservedObject private var object = ObservableObject1()
@zntfdr
zntfdr / firebase-iOS-breakdown.swift
Last active May 28, 2024 12:49
Firebase iOS Version breakdown
// How to:
// 1. Open the Firebase Analytics Dashboard
// 2. Scroll to bottom, where you see the "Users by Device model" widget
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
// 5. Make sure to select “OS with version” and not “OS Version”
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date)
// 7. Click “Download file” on the new side bar, then “Download CSV"
// 8. Open the file and select the iOS/Android breakdown raw data
// 9. Replace the sample data in this script with your data
@sumitokamoi
sumitokamoi / Array+chunked.swift
Created October 18, 2019 08:45
Swiftで配列をn個の要素に分割する
extension Array {
func chunked(by chunkSize: Int) -> [[Element]] {
return stride(from: 0, to: self.count, by: chunkSize).map {
Array(self[$0..<Swift.min($0 + chunkSize, self.count)])
}
}
}
let arr = [0,1,2,3,4,5,6,7,8,9]
print(arr.chunked(by: 2)) // [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
@shaildyp
shaildyp / UIView+roundCorners.swift
Last active December 7, 2022 12:14
Backward compatible maskedCorners of iOS 11.
extension UIView {
func roundCorners(_ corners: CACornerMask, radius: CGFloat) {
if #available(iOS 11, *) {
self.layer.cornerRadius = radius
self.layer.maskedCorners = corners
} else {
var cornerMask = UIRectCorner()
if(corners.contains(.layerMinXMinYCorner)){
cornerMask.insert(.topLeft)
@fuxingloh
fuxingloh / UICollectionView.swift
Last active February 23, 2023 08:38
iOS Swift: How to count the width of the UILabel. And how to size UICollectionViewCell dynamically with label.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let text = collections[indexPath.row].name
let width = UILabel.textWidth(font: titleFont, text: text)
return CGSize(width: width + left + right, height: height)
}
@bvlion
bvlion / .vimrc
Last active July 13, 2022 08:34
vimrc
" 日本語入力設定
if has('multi_byte_ime') || has('xim')
" IME ON時のカーソルの色を設定(設定例:紫)
highlight CursorIM guibg=Purple guifg=NONE
" 挿入モード・検索モードでのデフォルトのIME状態設定
set iminsert=0 imsearch=0
" 挿入モードでのIME状態を記憶させない
inoremap <silent> <ESC> <ESC>:set iminsert=0<CR>
endif
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// by calling [NSURLProtocol registerClass:[MyURLProtocol class]]; in -application:didFinishLoadingWithOptions:, your protocol will have priority over any of the built-in protocols.
URLProtocol.registerClass(ActivityURLProtocol.self)
//URLProtocol.unregisterClass(ActivityURLProtocol.self)
print(URLSession.shared.configuration.protocolClasses)
}