Skip to content

Instantly share code, notes, and snippets.

View kuotinyen's full-sized avatar
🐛
feeds me

TK kuotinyen

🐛
feeds me
View GitHub Profile
@kuotinyen
kuotinyen / demo.swift
Last active January 30, 2024 14:51
20230109-SwiftRegex.swift
import Foundation
import XCTest
import RegexBuilder
// MARK: - Regex I
final class regTests: XCTestCase {
#warning("《Create a Regex》")
// 1. /<reg>/ -> build time
@kuotinyen
kuotinyen / twitter.hide.right_sidebar.js
Last active July 29, 2023 07:21
twitter.hide.right_sidebar.js
// ==UserScript==
// @name Hide Twitter SideBar
// @namespace https://holisticlawfirm.zeabur.app/
// @version 0.1
// @description Hide Twitter right side bar.
// @author tkuo
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// ==/UserScript==
@kuotinyen
kuotinyen / ToolbarDemoView.swift
Created August 29, 2021 10:48
ToolbarDemoView.swift
struct ToolbarDemoView: View {
@State var showDetail: Bool = false
var body: some View {
NavigationView {
ZStack {
Text("ToolbarDemoView")
}
.navigationTitle("Title")
.toolbar {
@kuotinyen
kuotinyen / SheetDemoView.swift
Last active August 29, 2021 10:41
SheetDemoView.swift
import SwiftUI
struct SheetDemoView: View {
enum SheetMode: Identifiable {
case first
case second
var id: Int { hashValue }
}
@kuotinyen
kuotinyen / dateDecodingFormatters.swift
Last active August 20, 2021 10:07
dateDecodingFormatters.swift
extension JSONDecoder {
var dateDecodingFormatters: [DateFormatter]? {
get { return nil }
set {
guard let formatters = newValue else { return }
self.dateDecodingStrategy = .custom { decoder in
let container = try decoder.singleValueContainer()
let dateString = try container.decode(String.self)
for formatter in formatters {
@kuotinyen
kuotinyen / demo.swift
Last active August 20, 2021 09:36
Worker demo
import Foundation
class AccountInfoWorker {
struct AccountInfo { /* properties */ }
typealias ApiResult = Result<AccountInfo, Error>
typealias ApiCompletion = (ApiResult) -> Void
func fetchAccountInfo(id: String, completion: @escaping ApiCompletion) { /* IMP */ }
}
@kuotinyen
kuotinyen / UITextField + DebounceThrottle.swift
Created March 12, 2020 17:05
Add UITextField debounce and throttle ability with stupid simple way.
extension UITextField {
private static var _texts = [String: [String]]()
var texts: [String] {
get {
let tmpAddress = String(format: "%p", unsafeBitCast(self, to: Int.self))
return UITextField._texts[tmpAddress] ?? []
}
set {
let tmpAddress = String(format: "%p", unsafeBitCast(self, to: Int.self))
UITextField._texts[tmpAddress] = newValue
@kuotinyen
kuotinyen / MapGuideAction.md
Created December 21, 2018 10:22
launch iOS system map app to guide location.

Usage

MapGuideManager.guide(from: nil, to:job.gps.location, with: job.companyName)

Extension

class MapGuideManager {
    class func guide(from startPoint: CLLocationCoordinate2D? = nil, to destination: CLLocationCoordinate2D? = nil, with destinationTitle: String) {
        
@kuotinyen
kuotinyen / UITableViewCell+Base.md
Created December 21, 2018 09:56
a base tableView cell for setup views.
class BaseTableViewCell: UITableViewCell {
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
 fatalError("init(coder:) has not been implemented")
@kuotinyen
kuotinyen / UIViewController+Base.md
Created December 21, 2018 09:55
a base viewController for setup views.

Extension

class BaseVC: UIViewController {

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }