Skip to content

Instantly share code, notes, and snippets.

View eneveu's full-sized avatar

Etienne Neveu eneveu

  • Paradigm Kick
  • Paris
View GitHub Profile
@eneveu
eneveu / ImplicitClassExample.scala
Last active January 7, 2019 14:32
Should I use "implicit def" or "implicit class" for an API ?
package implicitclass
import scala.collection.JavaConverters._
import scala.collection.immutable._
import com.typesafe.config.{ Config, ConfigFactory }
trait ConfigSupport {
def customLoadConfig(): Config = ConfigFactory.load()
@eneveu
eneveu / Chrome console errors
Created January 22, 2015 12:55
jQuery + curl.js
bootstrap.js:8 Uncaught Error: Bootstrap's JavaScript requires jQuery
slidebars.js:346 Uncaught ReferenceError: jQuery is not defined
@eneveu
eneveu / MaskForDiv.css
Created November 19, 2013 16:25
CSS mask that fills the parent div
.mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10000;
background-color: #777;
opacity: 0.4;
}
@eneveu
eneveu / GwtCreateExample.java
Last active December 26, 2015 23:39
GWT.create() performance question: Do I improve performances if I store the result of GWT.create() in a constant, or does the GWT compiler do that for me?
@Nonnull
public SafeHtml decorateWithLinkIfAny(@Nullable String link, @Nonnull SafeHtml content) {
return link == null ? content : SAFE_HTML_TEMPLATES.link(UriUtils.fromString(link), content);
}
private static final MySafeHtmlTemplates SAFE_HTML_TEMPLATES = GWT.create(MySafeHtmlTemplates.class);
// vs
@eneveu
eneveu / TreeBuilder.java
Last active December 11, 2015 12:58
DSL to build a tree or "hierarchy" in a visually elegant way --> when you want the hierarchy to be easily readable in the source file
package rubber.duck;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Lists;
import org.apache.commons.lang.NotImplementedException;
import java.util.List;
// TODO: generate the tree from the list of temporary element holders
// fail fast if an user calls methods in the wrong order
@eneveu
eneveu / Foo
Created January 22, 2013 18:13
DSL to build an enum hierarchy in a visually elegant way
package rubber.duck;
import com.google.common.collect.ImmutableSet;
public enum Foo implements FooHierarchy.Node {
ONE,
TWO,
THREE,
FOUR,
FIVE,
@eneveu
eneveu / CollectionSerializationUtils.java
Created August 29, 2012 09:34
Static utility methods to read/write collections to/from a byte stream, using protostuff.
package com.foo.serialization;
import com.dyuproject.protostuff.LinkedBuffer;
import com.dyuproject.protostuff.ProtostuffIOUtil;
import com.dyuproject.protostuff.Schema;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@eneveu
eneveu / MultipleGuiceSingletonsTest.java
Created August 19, 2011 11:17
How to bind multiple Guice singletons of the same type under different binding annotations
/**
* Copyright (C) 2011 Etienne Neveu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software