Skip to content

Instantly share code, notes, and snippets.

İbrahim Süren ibrahimsn98

Block or report user

Report or block ibrahimsn98

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ibrahimsn98
ibrahimsn98 / AdbCommands
Created Mar 10, 2019 — forked from Pulimet/AdbCommands
Adb useful commands list
View AdbCommands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
@ibrahimsn98
ibrahimsn98 / jwt-expiration.md
Created Feb 8, 2019 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?
View jwt-expiration.md

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@ibrahimsn98
ibrahimsn98 / MainActivity.kt
Last active Jan 1, 2019
Android-Live-Shared-Preferences-Gist8
View MainActivity.kt
liveSharedPreferences.listenMultiple(listOf("bool1", "bool2", "bool3"), false).observe(this, Observer<Pair<String, Boolean>> { value ->
Log.d(TAG, "key: ${value!!.first} value: ${value.second}")
})
@ibrahimsn98
ibrahimsn98 / LiveSharedPreferences.kt
Created Dec 31, 2018
Android-Live-Shared-Preferences-Gist7
View LiveSharedPreferences.kt
public fun <T> listenMultiple(keys: List<String>, defaultValue: T): MultiPreference<T> {
return MultiPreference(updates, preferences, keys, defaultValue)
}
@ibrahimsn98
ibrahimsn98 / MultiPreference.kt
Last active Jul 27, 2019
Android-Live-Shared-Preferences-Gist6
View MultiPreference.kt
class MultiPreference<T> constructor(private val updates: Observable<String>,
private val preferences: SharedPreferences,
private val keys: List<String>,
private val defaultValue: T) : MutableLiveData<Map<String, T>>() {
private var disposable: Disposable? = null
private val values = mutableMapOf<String, T>()
init {
for (key in keys)
@ibrahimsn98
ibrahimsn98 / MainActivity.kt
Last active Jan 1, 2019
Android-Live-Shared-Preferences-Gist5
View MainActivity.kt
class MainActivity : AppCompatActivity() {
private const val TAG = "MainActivity"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
val liveSharedPreferences = LiveSharedPreferences(preferences)
@ibrahimsn98
ibrahimsn98 / LiveSharedPreferences.kt
Last active Jul 27, 2019
Android-Live-Shared-Preferences-Gist4
View LiveSharedPreferences.kt
class LiveSharedPreferences constructor(private val preferences: SharedPreferences) {
private val publisher = PublishSubject.create<String>()
private val listener = OnSharedPreferenceChangeListener { _, key -> publisher.onNext(key) }
private val updates = publisher.doOnSubscribe {
preferences.registerOnSharedPreferenceChangeListener(listener)
}.doOnDispose {
if (!publisher.hasObservers())
preferences.unregisterOnSharedPreferenceChangeListener(listener)
@ibrahimsn98
ibrahimsn98 / LivePreference.kt
Last active Jul 27, 2019
Android-Live-Shared-Preferences-Gist3
View LivePreference.kt
class LivePreference<T> constructor(private val updates: Observable<String>,
private val preferences: SharedPreferences,
private val key: String,
private val defaultValue: T) : MutableLiveData<T>() {
private var disposable: Disposable? = null
override fun onActive() {
super.onActive()
value = (preferences.all[key] as T) ?: defaultValue
@ibrahimsn98
ibrahimsn98 / LiveSharedPreferences.kt
Last active Jul 27, 2019
Android-Live-Shared-Preferences-Git2
View LiveSharedPreferences.kt
class LiveSharedPreferences constructor(private val preferences: SharedPreferences) {
private val publisher = PublishSubject.create<String>()
private val listener = OnSharedPreferenceChangeListener { _, key -> publisher.onNext(key) }
private val updates = publisher.doOnSubscribe {
preferences.registerOnSharedPreferenceChangeListener(listener)
}.doOnDispose {
if (!publisher.hasObservers())
preferences.unregisterOnSharedPreferenceChangeListener(listener)
@ibrahimsn98
ibrahimsn98 / MainActivity.kt
Created Dec 31, 2018
Android-Live-Shared-Preferences-Git1
View MainActivity.kt
class MainActivity : AppCompatActivity() {
private val preferences = PreferenceManager.getDefaultSharedPreferences(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
var listener: SharedPreferences.OnSharedPreferenceChangeListener =
You can’t perform that action at this time.