Skip to content

Instantly share code, notes, and snippets.

View Narigo's full-sized avatar

Joern Bernhardt Narigo

View GitHub Profile
@Narigo
Narigo / mediarecorder.js
Created February 4, 2022 00:55
Poor man's recorder - to be used in browsers dev tools; start with recorder.record(); and stop with recorder.stop();
let recorder = await navigator.mediaDevices
.getUserMedia({ audio: true })
.then((mediaSourceObject) => {
document.createElement("audio").srcObject = mediaSourceObject;
const recorder = new MediaRecorder(mediaSourceObject);
let data = [];
recorder.ondataavailable = (e) => data.push(e.data);
recorder.onstop = () => {
const blob = new Blob(data, { type: "audio/ogg" });
data = [];
@Narigo
Narigo / figma-underdog-plugins.sh
Last active January 22, 2021 19:31
Find #Figma plugins with a high like-to-install ratio
# find #Figma plugin underdogs
curl https://raw.githubusercontent.com/yuanqing/figma-plugins-stats/gh-pages/index.json > d.json
node <<'EOF'|head -n 50
let d = require("./d.json");
let r = (p) => p.likeCount / p.installCount;
d.plugins
.sort((a, b) => r(b) - r(a))
.forEach((p, i) => console.log(`${i + 1}. ${p.name} by ${p.publisherName}`));
EOF
@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>
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 / 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}
@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);
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();
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
@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] {
@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) =