Skip to content

Instantly share code, notes, and snippets.

View ArnyminerZ's full-sized avatar
🏠
Working from home

Arnau Mora ArnyminerZ

🏠
Working from home
View GitHub Profile
@LongClipeus
LongClipeus / HashUtils.kt
Last active March 13, 2024 11:54
How to generate checksum hash for a file in Kotlin
import StringUtils.encodeHex
import java.io.File
import java.io.FileInputStream
import java.io.InputStream
import java.security.MessageDigest
object HashUtils {
const val STREAM_BUFFER_LENGTH = 1024
suspend fun <T> Task<T>.awaitTask(): T? = suspendCoroutine { continuation ->
this.addOnCompleteListener { task ->
if (task.isSuccessful) {
continuation.resume(task.result)
} else {
continuation.resumeWithException(task.exception!!)
}
}
}
@rithvikvibhu
rithvikvibhu / LICENSE
Last active December 1, 2024 07:43
Get tokens for Google Home Foyer API
MIT License
Copyright (c) 2020 Rithvik Vibhu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ToBoehmK
ToBoehmK / MutableCollectionLiveData.kt
Last active March 12, 2022 19:06
A MutableList- and CollectionLiveData implementation based on Android Architecture Components LiveData which allows to get notified on collection changes.
/*
* Copyright [2019] [Tobias Boehm]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tuesd4y
tuesd4y / PasswordUtils.kt
Created September 4, 2017 16:18
kotlin password hashing helper
//probably this should be something like a JavaEE Singleton...
object PasswordUtils {
val random = SecureRandom()
fun generateSalt(): ByteArray {
val salt = ByteArray(16)
random.nextBytes(salt)
return salt
}
@dant3
dant3 / nullable.kt
Created August 4, 2017 12:38
Check if kotlin generic is nullable type
inline fun <reified T> isNullable(): Boolean = null is T