Skip to content

Instantly share code, notes, and snippets.

LiBe libetl

Block or report user

Report or block libetl

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
@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
@libetl
libetl / KotlinBuilderTest.kt
Created Oct 17, 2018
simplest kotlin builder
View KotlinBuilderTest.kt
fun main(args: Array<String>) {
val choosenMenu = menu {
fish
chips
hamburger
}
println(choosenMenu)
}
View package.json
{
"name": "yamlchecker",
"version": "0.0.1",
"private": true,
"dependencies": {
"yamljs": "latest"
},
"devDependencies": {
"webpack": "latest"
}
View readGtfsDumps.js
const {get} = require('axios')
const unzip = require('yauzl')
const eventStream = require('event-stream')
const keys = {
agency: ['agency_id'],
stops: ['stop_id'],
calendar: ['service_id'],
calendar_dates: ['date', 'service_id'],
routes: ['route_id'],
View react-button.js
import React from 'react'
import {
Animated, Image, IsNative, LoadPicture, Text, TouchableOpacity, TouchableWithoutFeedback, View} from 'react-native'
export default class RoundButton extends React.Component {
constructor(props) {
super(props)
this.state = {width: `${100/props.nbButtons}%`, height: `${100/props.nbButtons}%`,
fadeAnim: new Animated.Value(0), longPressHeight: 0}
this.measureButton = this.measureButton.bind(this)
@libetl
libetl / benchmark.js
Last active Nov 29, 2017
Benchmark.js
View benchmark.js
const benchmark = ({theContestants, howManyTimes, forThisWork, barSettings, asText, logInConsole, seedInit}) => {
const timestamp = () => {
const hrTime = process.hrtime();
return hrTime[0] * 1000000 + hrTime[1] / 1000
}
const asNumbers = (name, duration) => `[${name.padStart(20)}]: ${`${(duration).toFixed(5)}`.padStart(15)} µs, ${`${((duration) / 1000).toFixed(0)}`.padStart(5)} ms, ${`${((duration) / 1000000).toFixed(2)}`.padStart(5)} s`
const asBar = (between0And1, histogramDisplay = barSettings) => {
const peak = between0And1 * histogramDisplay.width
const interval = histogramDisplay.width / histogramDisplay.gradient.length
@libetl
libetl / CrashesJavac.java
Created Oct 13, 2017
How to crash javac
View CrashesJavac.java
public class TestExtendConsumer {
@FunctionalInterface public interface NumberConsumer<E extends Number> extends java.util.function.Consumer<E>{void accept(E number);}
private static <E extends Number> void extend(E number) {
System.out.println(number);
}
public static void main(String[] args) {
NumberConsumer numberConsumer = TestExtendConsumer::extend;
You can’t perform that action at this time.