Skip to content

Instantly share code, notes, and snippets.

@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[]) {
<?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 / 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
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 / 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 {
@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"));
});
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;
public AbstractHandler getHandler() {
return new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (request.getPathInfo().equals(route + "/nextCommand")) {
String nextCommand;
synchronized (elevator) {
nextCommand = elevator.nextCommand();
}
response.getWriter().print(nextCommand);
@ybonnel
ybonnel / GoloCountlines.sh
Last active December 18, 2015 21:39
Golo count lines
git clone https://github.com/golo-lang/golo-lang.git
find golo-lang -type f -exec wc -l {} \; | grep -v '.git' | grep '\.' | while read a
do
echo "$a `echo $a | cut -d'.' -f2`"
done | awk '{
total += $1;
total_by_type[$3] += $1
}
END {
print "Nombre de lignes totales de golo : "total;
@ybonnel
ybonnel / exception
Created May 2, 2013 12:59
Error in Infinitest on intellij (12.1/Windows)
Error during dispatching of java.awt.event.InvocationEvent[INVOCATION_DEFAULT,runnable=org.infinitest.EventNormalizer$1$1@1b9086c,notifier=null,catchExceptions=false,when=1367497227897] on sun.awt.windows.WToolkit@10cbe41: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.infinitest.EventNormalizer$1$1.run(EventNormalizer.java:142)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)