Skip to content

Instantly share code, notes, and snippets.

@segphault
segphault / iterator.md
Created Feb 25, 2018
Async iterator issue
View iterator.md

I recently began experimenting with async iterators, using the --harmony flag in Node 9.5. After reading through the MDN docs, I figured that it might be interesting to make a function that takes the values yielded by an async generator function and serves them as an SSE event stream. The following is a simple, contrived example:

const http = require("http");

const timer = time =>
  new Promise(resolve => setTimeout(resolve, time));

async function* counter() {
  let counter = 0;
@segphault
segphault / rollup.config.js
Created Jan 11, 2018
Bundling remote dependencies with rollup
View rollup.config.js
const http = require("http");
const https = require("https");
const isRemote = path =>
path.startsWith("http://") || path.startsWith("https://");
const protocol = url =>
url.startsWith("https://") ? https : http;
const fetch = url =>
@segphault
segphault / index.html
Created Jul 6, 2016
Horizon bookmark manager example using React and RxJS
View index.html
<html>
<head>
<script type="text/javascript" src="//npmcdn.com/@reactivex/rxjs@5.0.0-beta.9/dist/global/Rx.umd.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.10.3/babel.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/react/15.2.0/react.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/react/15.2.0/react-dom.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
<script type="text/javascript" src="/horizon/horizon.js"></script>
<script type="text/babel" src="views.js"></script>
View TrainClock.qml
import QtQuick 2.3
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
import QtQuick.Controls 1.1
ApplicationWindow {
id: root
width: 540
height: 420
color: "black"
@segphault
segphault / README.md
Last active Oct 5, 2018
Pipe data from a RethinkDB changefeed into Plotti
View README.md

RethinkDB Changfeeds and Plottico

This example shows how to take the output of a RethinkDB changefeed and send it to Plottico, a microservice that generates embeddable streaming graphs. This example uses Plottico's hosted infrastructure, but you can also self-host your own Plottico server using the code from Plottico's GitHub repository.

@segphault
segphault / app.js
Created Jun 15, 2015
Todo list app built with deepstream and RethinkDB
View app.js
var DSServer = require("deepstream.io");
var DSRethinkConnector = require("deepstream.io-storage-rethinkdb");
var server = new DSServer();
server.set("host", "localhost");
server.set("port", 6020);
server.set("storage", new DSRethinkConnector({
port: 28015,
host: "localhost",
@segphault
segphault / main.go
Created Feb 10, 2015
An IRC bot written in Go that provides notification when a RethinkDB cluster experiences issues
View main.go
package main
import (
"code.google.com/p/gcfg"
"fmt"
r "github.com/dancannon/gorethink"
irc "github.com/fluffle/goirc/client"
"log"
"strings"
)
@segphault
segphault / monitor.go
Created Feb 5, 2015
A Go-based implementation of the RethinkDB cluster monitoring demo
View monitor.go
package main
import (
"fmt"
r "github.com/dancannon/gorethink"
"github.com/googollee/go-socket.io"
"log"
"net/http"
)
@segphault
segphault / app.js
Created Jan 18, 2015
Simple iOS app built with NativeScript
View app.js
var application = require("application");
application.mainModule = "app/main";
application.start();
@segphault
segphault / app.py
Created Dec 5, 2014
Flask application that serves RethinkDB data in CSV format
View app.py
#!/usr/bin/env python
from csvkit.convert.js import json2csv
from collections import OrderedDict
from flask import Flask
import rethinkdb as r
import json, StringIO
config = {
"port": 8096,