Skip to content

Instantly share code, notes, and snippets.


Alex Gotev gotev

View GitHub Profile
gotev /
Last active Apr 28, 2021
macOS GitHub SSH Certificates Helper
#!/bin/bash -e
echo "macOS Helper to configure SSH Key to use with GitHub"
echo "based off of instructions reported at:"
echo ""
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "This script is designed for macOS only..."
echo "exiting"
gotev / SafeClickListener.kt
Created Apr 8, 2020
Android Safe Click Listener
View SafeClickListener.kt
import android.os.SystemClock
import android.view.View
* Implements the "throttle first" mechanism for click listeners, to prevent double taps.
* How it works:
* - Define a sampling window time (default: 500ms)
* - when you click at time T0, the first click gets dispatched and the subsequent ones happening
* between T0 and T0 + WindowTime gets ignored
gotev / ISO8601DateJSONDecoder.swift
Created Feb 21, 2020
iOS ISO8601 Date JSON Decoder
View ISO8601DateJSONDecoder.swift
let jsonDecoder: JSONDecoder = {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .custom { decoder in
let container = try decoder.singleValueContainer()
let string = try container.decode(String.self)
let formatter1 = ISO8601DateFormatter()
formatter1.formatOptions = [.withInternetDateTime]
let formatter2 = ISO8601DateFormatter()
formatter2.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
guard let date = string) ?? string) else {
gotev / NavigationBottomBarSectionsStateKeeperWorkaround.kt
Last active May 25, 2021
JetPack Bottom Bar Navigation with Sections State
View NavigationBottomBarSectionsStateKeeperWorkaround.kt
package jetpack.navigation.workaround
import android.os.Bundle
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.navigation.NavController
import androidx.navigation.ui.setupActionBarWithNavController
import java.lang.ref.WeakReference
gotev / resize-images
Created Oct 30, 2019
Batch resize images
View resize-images
sips -Z 640 *.jpg
gotev / static-json-server
Last active Sep 27, 2019
Static JSON File Server in Python 3
View static-json-server
#!/usr/bin/env python3
from http.server import HTTPServer, BaseHTTPRequestHandler
import os
base_path = os.path.dirname(__file__)
class StaticServer(BaseHTTPRequestHandler):
def execute_request(self):
filename = 'cached-responses' + self.path + '.json'
gotev /
Last active Jun 16, 2019
Enable GitFlow in SourceTree

Clone both master and develop branches and switch on develop:


Right click on an empty space on the toolbar:


Drag GitFlow on your toolbar and click Done:

gotev / ISO8601DateTimeAdapters.kt
Created Jun 6, 2019
ISO8601 Gson Type Adapters
View ISO8601DateTimeAdapters.kt
import org.threeten.bp.*
private fun LocalDateTime.toISO8601UTCString() = withNano(0).atOffset(ZoneOffset.UTC).toString()
abstract class NullableTypeAdapter<T> : TypeAdapter<T>() {
override fun write(writer: JsonWriter?, value: T) {
View ExtendedGsonFactory.kt
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.lang.reflect.Type
gotev / Optional.kt
Created May 27, 2019
Optional Subject
View Optional.kt
import io.reactivex.subjects.BehaviorSubject
class Optional<T>(private val value: T? = null) {
companion object {
fun <T> subject() = BehaviorSubject.createDefault(Optional<T>())
fun isPresent() = value != null