Skip to content

Instantly share code, notes, and snippets.

View AlonsoFloo's full-sized avatar
💻
󠀠

Florian ALONSO AlonsoFloo

💻
󠀠
View GitHub Profile
-----BEGIN CERTIFICATE-----
MIIGAjCCA+qgAwIBAgIJAM64OixRfexaMA0GCSqGSIb3DQEBCwUAMIGVMQswCQYD
VQQGEwJGUjETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQg
V2lkZ2l0cyBQdHkgTHRkMSgwJgYDVQQDDB9GbG9yaWFuIFlhbm5pY2sgRnJlZGVy
aWMgQUxPTlNPMSQwIgYJKoZIhvcNAQkBFhVhbG9uc28uZmxvb0BnbWFpbC5jb20w
HhcNMjMwMTE0MTEzMTM0WhcNMzgwMTEwMTEzMTM0WjCBlTELMAkGA1UEBhMCRlIx
EzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMg
UHR5IEx0ZDEoMCYGA1UEAwwfRmxvcmlhbiBZYW5uaWNrIEZyZWRlcmljIEFMT05T
TzEkMCIGCSqGSIb3DQEJARYVYWxvbnNvLmZsb29AZ21haWwuY29tMIICIjANBgkq
hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEApd14qTZI+zp1VurtZmsViY1d/uZWBtY0

Keybase proof

I hereby claim:

  • I am AlonsoFloo on github.
  • I am alonsofloo (https://keybase.io/alonsofloo) on keybase.
  • I have a public key whose fingerprint is FA55 3E1F F6FE EE77 190E 92B7 9FF6 013D C330 70F2

To claim this, I am signing this object:

@AlonsoFloo
AlonsoFloo / get_pin_from_certificate.py
Last active October 15, 2020 15:24
Get SHA256 suject fingerprint of a PEM certificate (original : https://github.com/datatheorem/TrustKit)
#!/usr/bin/env python
"""Helper script to generate a TrustKit or HPKP pin from a PEM/DER certificate file.
How to use :
> python get_pin_from_certificate.py cert.pem
> python get_pin_from_certificate.py --type DER ca.der
"""
from __future__ import print_function
from subprocess import Popen, PIPE
from sys import stdin
@AlonsoFloo
AlonsoFloo / Settings.swift
Created November 19, 2019 16:11
Swift UserDefault property wrapper with @propertyWrapper, thanks to https://medium.com/@nimjea
class Settings {
static let shared: Settings = {
Settings()
}()
private init() {
// Private, due to singleton
}
@UserDefaultProperty("on_off", defaultValue: false)
@AlonsoFloo
AlonsoFloo / ForegroundServiceLauncher.kt
Created July 29, 2019 07:42
ForegroundServiceLauncher is a helper for using better foreground functions
class ForegroundServiceLauncher(private val serviceClass: Class<out Service>) {
private var isStarting = false
private var shouldStop = false
@Suppress("DEPRECATION")
private inline fun <reified T : Service> Context.isServiceRunning(service: Class<out T>) =
(getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager)
.getRunningServices(Integer.MAX_VALUE)
.any { it.service.className == service.name }
@AlonsoFloo
AlonsoFloo / SharedChamberPropertyDelegate.kt
Created July 13, 2019 13:20
Koltin property delegate tools for Android SharedChamber --> https://github.com/afiqiqmal/SharedChamber
class SharedChamberPropertyDelegate<T>(
private val sharedChamber: SharedChamber<Any>,
private val defaultValue: T,
private val getter: SharedChamber<Any>.(String, T) -> T,
private val setter: SharedChamber<Any>.(String, T) -> Unit
) : ReadWriteProperty<Any, T> {
override fun getValue(thisRef: Any, property: KProperty<*>): T =
sharedChamber.getter(property.name, defaultValue)
@AlonsoFloo
AlonsoFloo / SharedPreferenceManager.kt
Last active July 19, 2019 13:28
Koltin property delegate tools for Android SharedPreferences
class SharedPreferenceManager(
val context: Context
) : SharedPreferences.OnSharedPreferenceChangeListener {
private val sharedPreferences by lazy {
PreferenceManager.getDefaultSharedPreferences(context)
}
private val propertyChangeListeners = hashMapOf<String, HashSet<() -> Unit>>()
@AlonsoFloo
AlonsoFloo / AndroidWorkerInjection.kt
Last active July 13, 2019 13:16
Kotlin tools for WorkManager Dagger injection
interface HasWorkerInjector {
fun workerInjector(): AndroidInjector<Worker>
}
class AndroidInjection {
companion object {}
}
fun AndroidInjection.Companion.inject(worker: Worker) {
@AlonsoFloo
AlonsoFloo / AbstractBindableItem.java
Last active February 13, 2019 16:47
FastAdapter MVVM generic class
public abstract class AbstractBindableItem<Item extends AbstractBindableItem & IItem & IClickable, VH extends FastBindableViewHolder<Item, Binding>, VM extends AndroidViewModel, Binding extends ViewDataBinding> extends AbstractItem<Item, VH> {
@NotNull
private VM viewModel;
public AbstractBindableItem(@NotNull VM viewModel) {
super();
this.viewModel = viewModel;
}
@AlonsoFloo
AlonsoFloo / BitmapUtil.java
Created December 9, 2018 11:45
Bitmap utils
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;