Skip to content

Instantly share code, notes, and snippets.


Cihat Gündüz Jeehut

View GitHub Profile
Jeehut / DurationFormat.kt
Last active Jan 14, 2022
Localized duration formatting in Kotlin using APIs in Android 9+ with fallback to English on Android 8 and lower.
View DurationFormat.kt
import android.os.Build
import java.util.Locale
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.days
import kotlin.time.hours
import kotlin.time.milliseconds
Jeehut / lint.swift
Last active Jul 19, 2020
AnyLint custom check with autocorrection for [SafeLocalizedStringKey](
View lint.swift
import AnyLint // @Flinesoft
try Lint.logSummaryAndExit(arguments: CommandLine.arguments) {
// MARK: - Variables
let swiftAppFiles: Regex = #"^(Shared|iOS|macOS)/App/Sources/.*\.swift$"#
// MARK: - Checks
// MARK: SafeLocalizedStringKey
let unsafeLocalizedStringKeyTypes: String = [
Jeehut / SafeLocalizedStringKey.swift
Created Jul 19, 2020
Exploring safer localization workflows in SwiftUI ...
View SafeLocalizedStringKey.swift
// Copyright © 2020 Flinesoft. All rights reserved.
import Foundation
import SwiftUI
public struct SafeLocalizedStringKey :
Jeehut / AppPreferences.kt
Last active Jan 31, 2020
SharedPreferences wrapper in Kotlin: copy & paste the code into a new `AppPreferences.kt` file & follow the 4 TODO steps.
View AppPreferences.kt
import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import androidx.core.content.edit
object AppPreferences {
private var sharedPreferences: SharedPreferences? = null
// TODO step 1: call `AppPreferences.setup(applicationContext)` in your MainActivity's `onCreate` method
fun setup(context: Context) {

Resource Targets


Jeehut /
Last active May 10, 2019
Migrating from default Xcode headers to shortened ones.

Migrating from Default Xcode headers to shortened ones

By default, Xcode creates comments like this:

//  AppDelegate.swift
//  HeaderDemo
//  Created by Cihat Gündüz on 09.05.19.
View TimeInterval.playground
import Foundation
//: ## The Problem
// property example
let pollingInterval: TimeInterval = 5
// method example
func animate(duration: TimeInterval = 20, animations: () -> Void) {