Skip to content

Instantly share code, notes, and snippets.

View Narigo's full-sized avatar

Joern Bernhardt Narigo

View GitHub Profile
@Narigo
Narigo / PingVerticle.java
Created May 10, 2013 10:50
Vert.x HttpClient not working with github.io -- just put it into vertx-gradle-template and ./gradlew runMod
package com.mycompany.myproject;
/*
* Copyright 2013 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@Narigo
Narigo / EventBus.scala
Last active December 19, 2015 03:59
trying to typeclass
class EventBus(internal: JEventBus) {
trait Sendable[T] {
def send(address: String, message: T)(handler: Message[T] => Unit)
def publish(address: String, message: T)
}
object Sendable {
def instance[T](jSend: ((String, T, Handler[JMessage[T]]) => JEventBus), jPublish: (String, T) => JEventBus): Sendable[T] = new Sendable[T] {
def publish(address: String, t: T) = {
jPublish(address, t)
}
@Narigo
Narigo / EventBus.scala
Created August 29, 2013 23:11
Pimp My Library example
package org.vertx.scala.core.eventbus
import org.vertx.java.core.eventbus.EventBus
import org.vertx.java.core.eventbus.Message
class RichEventBus(internal: EventBus) extends EventBus {
override def registerHandler[T <: Message[T]](address: String)(handler: T => Unit) =
internal.registerHandler(address, handler)
override def registerLocalHandler[T <: Message[T]](address: String)(handler: T => Unit) =
@Narigo
Narigo / typesafe-json.diff
Created October 2, 2013 17:29
Making json API typesafe... Is this a good idea?
diff --git a/src/main/scala/org/vertx/scala/core/json/Json.scala b/src/main/scala/org/vertx/scala/core/json/Json.scala
index d756a32..b6d32d5 100644
--- a/src/main/scala/org/vertx/scala/core/json/Json.scala
+++ b/src/main/scala/org/vertx/scala/core/json/Json.scala
@@ -17,51 +17,6 @@
import scala.annotation.implicitNotFound
-@implicitNotFound(msg = "Cannot find add operations for type ${T}")
-trait JsonElemOps[T] {
class YourTest extends TestVerticle {
// usual start(), etc.
private void afterPostActionDo(Handler<HttpClient> nextFn) {
final HttpClient client = vertx.createHttpClient().setHost("localhost").setPort(8080).setKeepAlive(false);
HttpClientRequest req = httpClient.post("/someapi", new Handler<HttpClientResponse>() {
public void handle(HttpClientResponse postResp) {
// do something with postResp
postResp.bodyHandler(new Handler<Buffer>() {
public void handle(Buffer body) {
// check body
class CreateHttpServer extends Verticle {
def start(): Future[Unit] = {
/* example-code-start */
vertx.createHttpServer(HttpServerOptions(
host = "localhost",
port = 8080
)).requestHandler(req => {
req.response().setChunked(true).end("<html><body><h1>Hello from vert.x!</h1></body></html>");
}).listen();
@Narigo
Narigo / gulpfile.js
Created February 14, 2015 17:57
Cordova + React + Gulp + live reload
var gulp = require('gulp');
gulp.task('sass', sassCompile);
gulp.task('assets', assetCopy);
gulp.task('scripts', scriptCompile);
gulp.task('clean', clean);
gulp.task('prepareAndReload', ['prepare'], reloader);
gulp.task('prepare', ['default'], cordovaPrepare);
gulp.task('dev', ['default'], liveReloadServer);
@Narigo
Narigo / HttpDownloadTest.scala
Created July 18, 2016 10:25
Test for Vertx 3 Scala support
package io.vertx.lang.scala.http
import io.vertx.core.file.OpenOptions
import io.vertx.scala.core.Vertx
import io.vertx.scala.core.streams.Pump
import org.junit.runner.RunWith
import org.scalatest.concurrent.AsyncAssertions
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FlatSpec, Matchers}
import Vue from "vue";
import { storiesOf } from "@storybook/vue";
import { action } from "@storybook/addon-actions";
import DropZone from "./DropZone.vue";
Vue.component("DropZone", DropZone);
storiesOf("DropZone", module)
.add("default", () => ({
@Narigo
Narigo / index.html
Created January 21, 2021 19:46
data URIs are working in the browser 🤯
<!DOCTYPE html>
<html>
<body>
seeing the alert?
<script src="main.js" type="module"></script>
</body>
</html>