Skip to content

Instantly share code, notes, and snippets.

@segphault
segphault / videotest2.html
Created January 20, 2012 10:09
HTML5 photo booth
<html>
<head>
<title>HTML5 Photo Booth</title>
</head>
<body>
<h2>HTML5 Photo Booth</h2>
<video id="live" autoplay></video>
<canvas id="snapshot" style="display:none"></canvas>
@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 / 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 / app.py
Created December 5, 2014 19:14
Flask application that serves RethinkDB data in CSV format
#!/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,
@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 / 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 =>
#!/usr/bin/env python
import SimpleHTTPServer
from gwibber import microblog, config
from mako.template import Template
PORT = 10002
def generate_html(messages):
return Template("""
@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 / 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/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>