Skip to content

Instantly share code, notes, and snippets.

View mathieuancelin's full-sized avatar

Mathieu ANCELIN mathieuancelin

View GitHub Profile
interface Future<T> {
/**
* Creates a {@code Future} with the given java.util.concurrent.CompletableFuture, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}
*
* @param completableFuture A {@link java.util.concurrent.CompletableFuture}
* @param <T> Result type of the Future
* @return A new {@code Future} wrapping the result of the Java future
* @throws NullPointerException if future is null
*/
static <T> Future<T> fromJavaCompletableFuture(CompletableFuture<T> completableFuture) {
<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() {
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test with ES6 and JSX</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<div id="app"></div>
@mathieuancelin
mathieuancelin / pretty.scala
Created October 31, 2016 11:07
Prettify as a typeclass
import play.api.libs.json._
import scala.xml.{Elem, Node}
package object pretty {
trait CanPrettify[A] {
def prettify(value: A): String
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World with React</title>
</head>
<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>
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { schema } = require('./graphql-wines');
const app = express();
app.use('/graphql', graphqlHTTP({
schema: schema,
pretty: true,
}));
@mathieuancelin
mathieuancelin / app-es6.html
Last active October 4, 2016 21:23
You don't need that much tool to use React
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<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>
@mathieuancelin
mathieuancelin / GoodOldPlayframework.scala
Last active April 28, 2019 19:06
A really dirty way to use Playframework without Guice
package old.play
import java.sql.Connection
import java.util.concurrent.atomic.{AtomicInteger, AtomicReference}
import java.util.concurrent.{Executors, ThreadFactory}
import akka.actor.{ActorSystem, Scheduler}
import akka.stream.Materializer
import play.api.ApplicationLoader.Context
import play.api.Mode.Mode
var AutoImage = function AutoImage(message) {
if (_.trim(message.html)) {
message.html = message.html.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 {
return part;
package batches.test
import scala.concurrent.{Promise, ExecutionContext, Future}
import scala.util.{Failure, Success}
object impl {
case class Step[T](step: T, e: Exception) extends RuntimeException()
implicit final class StepableFuture[A](future: Future[A]) {
def withStep[T](name: T)(implicit ec: ExecutionContext): Future[A] = {
val p = Promise[A]