Skip to content

Instantly share code, notes, and snippets.

@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 {
@ybonnel
ybonnel / elemjsx.es6
Created August 11, 2015 12:03 — forked from anonymous/elemjsx.es6
Use jsx with Elem.js
const Elem = require('elemjs');
Elem.jsx = (type, attributes, ...children) => {
if (attributes === null) {
return Elem.sel(type, children);
}
return Elem.el(type, attributes, children);
};
export default Elem;
import java.util.Optional;
public class TestOption {
public static void main(String[] args) {
// Avec option
System.out.println(getOption()
.filter(c -> c.age < 35)
.map(c -> "Age = " + c.age)
.orElse("Contact not found"));
<dependency>
<groupId>fr.ybonnel</groupId>
<artifactId>simpleweb4j</artifactId>
<version>1.0.0</version>
</dependency>
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(
() -> System.out.println(LocalTime.now().toString()),
0, 1, TimeUnit.SECONDS);
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) {
@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;