Skip to content

Instantly share code, notes, and snippets.

async function retrieveDB(){
return new Promise(resolve => {
const request = window.indexedDB.open("firebaseLocalStorageDb", 1);
request.onerror = function(event) {
console.log("Erreur lors de l'ouverture de la base de données.");
};
request.onsuccess = function(event) {
resolve(event.target.result);
@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 / 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 / Singleton.java
Created July 23, 2012 06:43
Solution de Java Quiz #45 de Coder breakfast
package fr.ybo.javaquiz;
public class Singleton {
private static final Singleton INSTANCE = new Singleton();
public static Singleton getInstance() {
return INSTANCE;
}
@ybonnel
ybonnel / Main.kt
Created November 28, 2018 10:53
Vertx BodyHandler stuck on big file
import io.vertx.core.Vertx
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler.BodyHandler
fun main(args: Array<String>) {
val vertx = Vertx.vertx()
val router = Router.router(vertx)
@ybonnel
ybonnel / gtdsbounded.sh
Created May 28, 2018 08:59
Just a little script to get bounds of GTFS file
unzip -p *.gtfs.zip stops.txt |
tr -d '"' |
tail -n+2 |
awk -F "," 'BEGIN{minLat=100; maxLat=-100; minLon=100; maxLon=-100 }{ if ( $5 > maxLat ) maxLat=$5; if ( $5 < minLat ) minLat =$5; if ($6 < minLon) minLon=$6; if ($6 > maxLon) maxLon = $6 }END {print minLat" "minLon" "maxLat" "maxLon}'
<html>
<body>
<div id="app"></div>
<script src="https://unpkg.com/react/dist/react.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/react-dom/dist/react-dom.min.js" type="text/javascript"></script>
<script type="text/javascript">
(function() {
var h = React.createElement;
var Hello = React.createClass({
render: function() {
Array.from(document.querySelectorAll('.message'))
.map(message => message.querySelector('.body'))
.forEach(message => {
message.innerHTML = message.innerHTML.split(/ /).map(function (part, index) {
if (part && part.length && part.length > 0) {
var codeMatch = part.match(/(?:```(\w*)[\n ]?([\s\S]*?)```+?)|(?:`(?:[^`]+)`)/);
var imgHrefMatch = part.match(/href=/i);
if (!codeMatch && !imgHrefMatch) {
return part.replace(/(https?:\/\/.*\.(?:png|jpeg|jpg|gif))/i, '<img src="$1" />');
} else {
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 / 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"));
});