Skip to content

Instantly share code, notes, and snippets.

View 1gravity's full-sized avatar

Emanuel Moecklin 1gravity

View GitHub Profile
Verifying that "emanuel_moecklin.id" is my Blockstack ID. https://onename.com/emanuel_moecklin

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@1gravity
1gravity / bitbucket-pipelines.yml
Last active September 8, 2023 09:44
Sample bitbucket pipeline for Android
image: androidsdk/android-30
pipelines:
branches:
master:
- step:
name: Create keystore and API key
script:
# create the keystore file and the google play api key file
- mkdir keys
txtPassword.validator()
.nonEmpty()
.atleastOneNumber()
.atleastOneSpecialCharacters()
.atleastOneUpperCase()
.addErrorCallback {
txtPassword.error = it
// it will contain the right message.
// For example, if edit text is empty,
// then 'it' will show "Can't be Empty" message
val uuidRegex = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$".toRegex()
data class Account(
var accountUUID: String,
var createdAt: Instant,
var modifiedAt: Instant,
var status: AccountStatus
) {
init {
runCatching {
val uuidRegex = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$".toRegex()
data class Account(
var accountUUID: String,
var createdAt: Instant,
var modifiedAt: Instant,
var status: AccountStatus
) {
init {
Validation<Account> {
val spec = validationSpec(messageBundle = "MyMessages", locale = Locale.FRENCH) {
constraints<MyClass> {
property(MyClass::color) {
notBlank()
inValues("GREEN", "WHITE", "RED")
size(3, 5)
}
property(MyClass::token) {
regexp("[A-Za-z0-9]+")
}
@1gravity
1gravity / MoshiArrayListJsonAdapter.kt
Created April 12, 2021 13:34
Json ArrayList adapter for Moshi
abstract class MoshiArrayListJsonAdapter<C : MutableCollection<T>?, T> private constructor(
private val elementAdapter: JsonAdapter<T>
) :
JsonAdapter<C>() {
abstract fun newCollection(): C
override fun fromJson(reader: JsonReader): C {
val result = newCollection()
reader.beginArray()
while (reader.hasNext()) {
@1gravity
1gravity / MoshiContentConverter.kt
Created April 12, 2021 15:24
Moshi as Ktor ContentNegotiation feature
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonEncodingException
import com.squareup.moshi.Moshi
import io.ktor.application.*
import io.ktor.features.*
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.request.*
import io.ktor.util.pipeline.*
import io.ktor.utils.io.*
@1gravity
1gravity / openapi_node.js
Created April 20, 2021 18:10
openapi_nodejs
/**
* @openapi
* /:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
*/
app.get('/', (req, res) => {