Skip to content

Instantly share code, notes, and snippets.

package fr.ybonnel.codestory;
import com.google.common.primitives.Longs;
import fr.ybonnel.codestory.path.jajascript.Flight;
import fr.ybonnel.codestory.path.jajascript.JajascriptService;
import org.junit.Ignore;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@ybonnel
ybonnel / Exercice1.scala
Created February 18, 2013 10:47
Tour de Hanoi en scala
package fr.ybo.battle
class Hanoi(val pile1: Seq[Int],
val pile2: Seq[Int],
val pile3: Seq[Int],
val history: Seq[Hanoi]) {
def isFinished: Boolean = {
pile1.isEmpty && pile2.isEmpty
}
@ybonnel
ybonnel / Exercice2.scala
Created February 18, 2013 13:43
Scalculate in scala
package fr.ybo.battle
object Exercice2 {
def specificSepRegExp = "\\[([^\\[\\]]+)]".r
def defaultSep = Seq("\n", ",")
def add(valeur:String):Int = {
@ybonnel
ybonnel / Exercice3.scala
Last active December 13, 2015 21:38
Calcul de score de bowling
package fr.ybo.battle
object Exercice3 {
def calculate(feuille:String):Int = {
// decomposition en frames
var countFrame = 0
var inFrame = false
@ybonnel
ybonnel / gist:5238180
Created March 25, 2013 15:58
log couchbase
16:41:57.799 [qtp0-10 - /data/channel] ERROR org.mortbay.log - EXCEPTION
net.spy.memcached.OperationTimeoutException: Timeout waiting for value
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1015) ~[ybo-tv-server.jar:na]
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1030) ~[ybo-tv-server.jar:na]
at fr.ybo.services.ChannelService.getAll(ChannelService.java:22) ~[ybo-tv-server.jar:na]
at fr.ybo.services.ServiceFactory.callService(ServiceFactory.java:22) ~[ybo-tv-server.jar:na]
at fr.ybo.web.DataServer.doGet(DataServer.java:62) ~[ybo-tv-server.jar:na]
at fr.ybo.WebServer.handle(WebServer.java:32) ~[ybo-tv-server.jar:na]
at org.mortbay.jetty.handler.HandlerList.handle(HandlerList.java:49) ~[ybo-tv-server.jar:na]
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) ~[ybo-tv-server.jar:na]
@ybonnel
ybonnel / tree.ceylon
Created March 27, 2013 10:16
Compilation error in ceylon
abstract class Tree() {
shared formal Integer evaluate();
}
class UnaryOperator(Tree branch, Integer f(Integer t)) extends Tree() {
evaluate() => f(branch.evaluate());
}
class Constant(Integer constantValue) extends Tree() {
@Test
public void testCalcul1() {
int i;
// Compile pas, on ne peux pas faire un '++' sur un int non-initialisé.
i = i++;
System.out.println(i);
}
@Test
public void testCalcul2() {
@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)
@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;
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);