Skip to content

Instantly share code, notes, and snippets.

Avatar
🇫🇷

Arnaud Esteve aesteve

🇫🇷
View GitHub Profile
@aesteve
aesteve / JDK8 OpenShift
Created Feb 19, 2015
Download Oracle's JDK 8 on Openshift DIY cartridge
View JDK8 OpenShift
cd $OPENSHIFT_DATA_DIR
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz
tar -zxvf jdk-8u31-linux-x64.tar.gz
rm -f jdk-8u31-linux-x64.tar.gz
# JAVA_HOME and PATH are set in startup hook according to these paths
@aesteve
aesteve / build.gradle
Last active Aug 29, 2015
Multi-project Vert.x 3 + Gradle
View build.gradle
if (!JavaVersion.current().java8Compatible) {
throw new IllegalStateException("This needs Java 8. You are using ${JavaVersion.current()}.")
}
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.1.1'
}
}
View JavaNature eclipse
<!-- comments / name / etc. -->
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
@aesteve
aesteve / JSXTransform
Last active Apr 9, 2018
Transforming JSX with nashorn
View JSXTransform
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
@aesteve
aesteve / _.mapjava 8
Created Feb 26, 2015
underscore.map Java 8
View _.mapjava 8
List<String> strings = new ArrayList<String>();
// ... populate list
List<String> mappedStrings = strings.stream().map(someString -> someString.toLowerCase()).collect(Collectors.toList());
@aesteve
aesteve / logback.groovy
Created Apr 2, 2015
Logback configuration for rolling files
View logback.groovy
import static ch.qos.logback.classic.Level.*
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
import ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP
appender("FILE", RollingFileAppender) {
file = "logs/server.log"
append = true
encoder(PatternLayoutEncoder) { pattern = "%d{HH:mm:ss.SSS} %-5level %logger{60} - %msg%n" }
@aesteve
aesteve / build.gradle
Created Apr 3, 2015
vertx-metrics-demo Gradle
View build.gradle
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'com.github.johnrengelman.shadow' version '1.2.1'
}
repositories {
mavenLocal()
mavenCentral()
@aesteve
aesteve / Perf example
Created Jul 10, 2015
Some example on what we could benchmark
View Perf example
// create an object
public class SomeObject {
public Date someDate;
public Integer someInt;
public String someString;
public Double someDouble;
}
// create vertx handler
router.put("/vertx", ctx -> {
View GroovyTestBase.groovy
import io.vertx.core.Handler
import io.vertx.groovy.ext.unit.Async
import io.vertx.groovy.ext.unit.TestContext
import io.vertx.groovy.ext.unit.junit.VertxUnitRunner
import org.junit.runner.RunWith
@RunWith(VertxUnitRunner.class)
abstract class GroovyTestBase {
public GroovyTestBase() {
View AuthorizationLogic.java
public static authorize(JsonObject authInfo, Handler<User> onAuthorized, Handler<Throwable> onFailure) {
return res -> {
if (res.succeeded()) {
User user = res.result();
user.isAuthorised("newsletter:edit:13", res2 -> {
if (res2.succeeded()) {
boolean hasPermission = res2.result();
if(hasPermission){
onAuthorized.handle(user);
}