This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>fr.ybonnel</groupId> | |
<artifactId>simpleweb4j</artifactId> | |
<version>1.0.0</version> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); | |
scheduler.scheduleAtFixedRate( | |
() -> System.out.println(LocalTime.now().toString()), | |
0, 1, TimeUnit.SECONDS); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
NewerOlder