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 / 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;
@libetl
libetl / PhoneParser.java
Last active Aug 31, 2017
How to parse a phone number with the google phone number util
View PhoneParser.java
import com.mycompany.mymodel.Phone;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import java.util.Locale;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import static com.mycompany.mymodel.Phone.phone;
@libetl
libetl / IgnoreCertificateValidation.java
Created Aug 28, 2017
Disable RestTemplate certificate validation
View IgnoreCertificateValidation.java
package foo.bar.config;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
View webpack.config.js
/* imports */
const webpack = require('webpack')
const path = require('path')
const fs = require('fs')
const unzip = require('unzip2')/* imports */
const webpack = require('webpack')
const path = require('path')
const fs = require('fs')
const unzip = require('unzip2')
const mkdirp = require('mkdirp')
You can’t perform that action at this time.