Skip to content

Instantly share code, notes, and snippets.

var TIMEFRAME = 20;
var BRIGHTNESS0 = 25;
var BRIGHTNESSSTEPS = 31; // up to 31 on Chrome that has better performance
if (navigator.userAgent.indexOf("Firefox")!=-1)
BRIGHTNESSSTEPS = 6;
var BRIGHTNESSTABLE = [];
var BRIGHTNESSTABLERGB = [];
var HISTORY = 25;
var GRIDWIDTH = 10;
var MESSAGESTEP = 30;
@ybonnel
ybonnel / after.java
Created January 3, 2014 14:00
SimpleWeb4j passe à java 8
jsonp("CALLBACK", "/jsonp", (param, routeParams) -> new Response<>("Hello World"));
get("/resource", (param, routeParams) -> new Response<>("Hello World"));
get("/resource/:name", Void.class, (param, routeParams) -> {
if (routeParams.getParam("name").equals("notfound")) {
throw new HttpErrorException(404);
}
return new Response<>("Hello " + routeParams.getParam("name"));
});
@ybonnel
ybonnel / Exercice6.java
Created January 8, 2014 14:23
Comparaison of Java 7 and Java 8 style
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.stream.IntStream;
/**
* I tried to compare Java 7 and Java 8 (functional way) syntax on a small problem.
* I Also compare performances just for fun.
*/
public class Exercice6 {
import java.util.Optional;
import java.util.TreeMap;
import java.util.function.BinaryOperator;
public class TemporelMap<K extends Comparable<K>, V> {
private TreeMap<K, V> treeMap = new TreeMap<>();
private BinaryOperator<V> add;
public TemporelMap(BinaryOperator<V> add) {
@ybonnel
ybonnel / strange ANR
Created February 6, 2014 07:41
Strange ANR on Android
----- pid 10319 at 2014-02-05 20:03:55 -----
Cmd line: fr.ybo.transportsrennes
JNI: CheckJNI is off; workarounds are off; pins=0; globals=150
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"AsyncTask #1" prio=5 tid=10 WAIT
| group="main" sCount=1 dsCount=0 obj=0x426aa108 self=0x52497008
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="net.codestory.http.StaticPagesTest" time="1.306" tests="8" errors="0" skipped="0" failures="1">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="D:\tools\com\sun\java\jdk\1.8.0\jre\bin"/>
<property name="java.vm.version" value="25.0-b63"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="java.vendor.url" value="http://java.oracle.com/"/>
<property name="path.separator" value=";"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
@ybonnel
ybonnel / Solution.java
Created May 13, 2014 07:10
Roller Coaster for codingame
// Read inputs from System.in, Write outputs to System.out.
// Your class name has to be Solution
import java.util.*;
import java.io.*;
import java.math.*;
class Solution {
public static void main(String args[]) {
@ybonnel
ybonnel / Solution.java
Created May 13, 2014 08:31
Solution for Surface on codingame
// Read inputs from System.in, Write outputs to System.out.
// Your class name has to be Solution
import java.util.*;
import java.io.*;
import java.math.*;
class Solution {
static boolean[][] terrain;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
public class SimpleCache<K, V> {
private final Function<K, V> initialValue;
private final ConcurrentHashMap<K, V> cache;
public SimpleCache(Function<K, V> initialValue) {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(
() -> System.out.println(LocalTime.now().toString()),
0, 1, TimeUnit.SECONDS);