Skip to content

Instantly share code, notes, and snippets.

View AndreasMattsson's full-sized avatar

Andreas Mattsson AndreasMattsson

View GitHub Profile
@emrul
emrul / Example.kt
Last active February 8, 2018 19:08
Hack to get Jsoniter to recognise JSONProperty annotations on Kotlin data classes
data class User(@JsonProperty("userName") val name: String)
val userObj = User("John")
JsoniterKotlinSupport.enable()
JsoniterAnnotationSupport.enable()
val jsonUserString = JsonStream.serialize(userObj)
// jsonUserString will contain: {"userName":"John"}
@yangweigbh
yangweigbh / SkipList.kt
Created July 14, 2017 10:07
SkipList Implemented in Kotlin
import java.util.*
/**
* Created by yangwei-ms on 2017/7/14.
*/
class SkipList<T>(private val comparator: Comparator<T>) {
private var curHeight: Int = 1
private val head: Node<T> = Node(null, MAX_HEIGHT)
private val rnd: Random = Random(System.currentTimeMillis())
@afshin-hoseini
afshin-hoseini / Swizzeling main bundle.swift
Created November 20, 2017 07:12
Forcing change localization for first iOS application run
//First, define a custom bundle class as like as below
import Foundation
//A key used for exchanging associated object
var _BUNDLE_KEY = 0
class BundleEx : Bundle {
override func localizedString(forKey key: String, value: String?, table tableName: String?) -> String {
@chibatching
chibatching / FlowThrottleDebounce.kt
Last active November 8, 2024 00:44
Throttle and Debounce on Flow Kotlin Coroutines
fun <T> Flow<T>.throttle(waitMillis: Int) = flow {
coroutineScope {
val context = coroutineContext
var nextMillis = 0L
var delayPost: Deferred<Unit>? = null
collect {
val current = SystemClock.uptimeMillis()
if (nextMillis < current) {
nextMillis = current + waitMillis
@adalinesimonian
adalinesimonian / block-the-blue.md
Last active December 27, 2024 22:02
Block all verified Twitter accounts on screen