Skip to content

Instantly share code, notes, and snippets.

@segphault
segphault / dl.js
Created July 5, 2022 20:57
Definition lists in Markdoc
const Markdoc = require('@markdoc/markdoc');
const example = `
{% definition-list %}
{% definition term="this is the term" %}
This is the definition
{% /definition %}
{% definition term="another term" %}
@segphault
segphault / iterator.md
Created February 25, 2018 00:43
Async iterator issue

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 January 11, 2018 21:02
Bundling remote dependencies with rollup
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 July 6, 2016 23:04
Horizon bookmark manager example using React and RxJS
<html>
<head>
<script type="text/javascript" src="//npmcdn.com/@reactivex/[email protected]/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>
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 October 5, 2018 08:22
Pipe data from a RethinkDB changefeed into Plotti

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 June 15, 2015 20:37
Todo list app built with deepstream and RethinkDB
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 February 10, 2015 20:53
An IRC bot written in Go that provides notification when a RethinkDB cluster experiences issues
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 February 5, 2015 22:48
A Go-based implementation of the RethinkDB cluster monitoring demo
package main
import (
"fmt"
r "github.com/dancannon/gorethink"
"github.com/googollee/go-socket.io"
"log"
"net/http"
)
@segphault
segphault / app.js
Created January 18, 2015 22:22
Simple iOS app built with NativeScript
var application = require("application");
application.mainModule = "app/main";
application.start();