Skip to content

Instantly share code, notes, and snippets.

Avatar

LiBe libetl

View GitHub Profile
@libetl
libetl / Helpers.kt
Last active Dec 1, 2020
React in Java
View Helpers.kt
package com.mycompany.react
import org.w3c.dom.html.HTMLElement
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.lang.reflect.Proxy
import kotlin.reflect.KClass
import kotlin.reflect.KType
import kotlin.reflect.full.createType
import kotlin.reflect.full.isSubtypeOf
View LoadYaml.kt
package com.mycompany.library.tools
import org.springframework.boot.env.YamlPropertySourceLoader
import org.springframework.core.env.ConfigurableEnvironment
import org.springframework.core.env.Profiles
import org.springframework.core.io.ClassPathResource
object LoadYaml {
data class LoadOptions(
View BatchCoroutinesStrategy.kt
package com.mycompany.infra.config
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.coroutineScope
@libetl
libetl / DatabaseSimulator.kt
Created Jul 31, 2020
DatabaseSimulator.kt
View DatabaseSimulator.kt
import io.mockk.every
import io.mockk.mockk
import java.sql.*
import java.time.ZonedDateTime
import javax.sql.DataSource
object DatabaseSimulator {
val registeredSQLServerMappings = mutableMapOf<String, ResultSet>()
val calledStatements = mutableListOf<String>()
@libetl
libetl / x2plusy2below1.json
Created Jun 1, 2020
neuralNetworkWeightsAndBiasesExample
View x2plusy2below1.json
{"weightsAndBiases":[[{"bias":-0.10071499664092819,"weights":[]},{"bias":-0.15018810063963497,"weights":[]}],[{"bias":-2.8468035812909434,"weights":[5.45721869905237,-3.148199059174658]},{"bias":-5.242078727744964,"weights":[-3.3284653639142725,10.876261776883684]},{"bias":-12.976066169035779,"weights":[36.003431279150426,6.242494143417826]},{"bias":-20.989904892589315,"weights":[13.402075212498223,51.79564730855186]}],[{"bias":-5.425858592065819,"weights":[-58.58740543154484,-32.269696973037284,18.54140361818438,10.084452534168838]}]],"parameters":["x","y"],"theory":"x^2+y^2<1","layersLength":[2,4,1]}
View fakemoment.ts
const moment = function moment(textValue: string | number, format: string) {
const timeOfTheDay = /^([0-9]{1,2}):([0-9]{1,2})$/.exec((textValue || "").trim())
const onlyTime = timeOfTheDay && new Date()
if (onlyTime && timeOfTheDay) onlyTime.setHours(parseInt(timeOfTheDay[1]), parseInt(timeOfTheDay[2]))
const date = !textValue ? new Date() :
!isNaN(textValue as number) ? new Date(textValue) :
!(textValue as string).trim() ? new Date() :
onlyTime ? onlyTime : new Date(textValue)
return {
date,
@libetl
libetl / CreditCardNumberChecker.ts
Created Nov 10, 2019
CreditCardNumberChecker.ts
View CreditCardNumberChecker.ts
type CardType = 'MasterCard' | 'Visa' | 'American Express' |
'JCB' | 'Diners Club' | 'Discover' | 'unknown'
type MajorIndustryIdentifier =
'ISO/TC 68' | 'Airlines' | 'Travel and entertainment and banking/financial' |
'Banking and financial' | 'Merchandising and banking/financial' |
'Petroleum' | 'Healthcare and telecommunications' | 'National assignment' |
'unknown'
type CreditCardGuessedInformation = {
View Router.kt
package org.toilelibre.libe
import kotlin.math.pow
import kotlin.reflect.full.companionObject
import kotlin.reflect.full.companionObjectInstance
import kotlin.reflect.full.declaredFunctions
import kotlin.reflect.full.memberProperties
class Router constructor(tableInput: String) {
@libetl
libetl / XmlToMap.kt
Last active Jun 25, 2019
XmlToMap.kt
View XmlToMap.kt
package xmltomap
@Suppress("UNCHECKED_CAST")
object XmlToMap {
private val CDATA = Regex("^<!\\[CDATA\\[(.+?)\\]\\]>")
private val OPENING_TAG = Regex("^<([^\\s>/]+)[^>]*>")
private val OPENING_CLOSING_TAG = Regex("^<([^\\s>/]+)[^>]*/>")
private val CLOSING_TAG = Regex("^</([^\\s>]+)>")
private val ATTRS = Regex("([a-zA-Z][a-zA-Z-0-9]*)=\"([^\"]*)\"")
private val UPPERCASE = Regex("[A-Z]+")
@libetl
libetl / RestTemplateInjector.kt
Last active Oct 31, 2018
RestTemplateInjector
View RestTemplateInjector.kt
package com.myservice.infra.testinterceptor
import com.fasterxml.jackson.databind.ObjectMapper
import org.springframework.http.HttpRequest
import org.springframework.http.HttpStatus
import org.springframework.http.client.ClientHttpRequestExecution
import org.springframework.http.client.ClientHttpRequestInterceptor
import org.springframework.http.client.ClientHttpResponse
import org.springframework.mock.http.client.MockClientHttpResponse
import java.io.File
You can’t perform that action at this time.