Skip to content

Instantly share code, notes, and snippets.

View RubenVerborgh's full-sized avatar

Ruben Verborgh RubenVerborgh

View GitHub Profile
@RubenVerborgh
RubenVerborgh / ttl-to-jsonld.js
Created October 21, 2016 07:08
Turtle to JSON-LD
const N3 = require('n3'),
fs = require('fs');
const stream = fs.createReadStream('file.ttl');
var first = true;
console.log('{');
const triples = new N3.Parser().parse(stream, (error, triple) => {
if (triple) {
if (first)
@RubenVerborgh
RubenVerborgh / snippet.html
Last active October 7, 2016 08:22
Failing fragment on Structured Data Testing Tool
<div vocab="http://schema.org" typeof="BlogPosting" resource="https://ruben.verborgh.org/blog/2016/06/22/querying-history-with-linked-data/">
<!-- Try adding and removing the line below: -->
<meta property="publisher" resource="https://ruben.verborgh.org/profile/#me">
<p resource="https://ruben.verborgh.org/profile/#me" typeof="Person">
<span property="name">Ruben Verborgh</span>
Index: src/reader.c
===================================================================
--- src/reader.c (revision 505)
+++ src/reader.c (working copy)
@@ -760,14 +760,24 @@
return r_err(reader, SERD_ERR_BAD_SYNTAX, "unexpected `%c'\n", c);
}
Ref ref = push_node(reader, SERD_LITERAL, "", 0);
- push_byte(reader, ref, eat_byte_safe(reader, c));
- while ((c = peek_byte(reader)) && in_range(c, 'a', 'z')) {
immediate = require('./lib/index');
var i = 2e7;
immediate(function next(i) {
if (i > 0)
immediate(next, i - 1);
}, i);
var i = 2e5, start = new Date();
void setImmediate(function next(i) {
if (i > 0)
setImmediate(next, i - 1);
else
console.log((new Date() - start) / 1000);
}, i);
diff --git 1/v1.0.6.css 2/v2.0.6.css
index a813751..bd0c9ab 100644
--- 1/v1.0.6.css
+++ 2/v2.0.6.css
@@ -1,27 +1,42 @@
+/**
+ * Ribbon theme for Shower HTML presentation engine
+ * shower-ribbon v2.0.6, https://github.com/shower/ribbon
+ * @copyright 2010–2016 Vadim Makeev, http://pepelsbey.net/
+ * @license MIT
#!/bin/bash
$1 $2 || echo -e "$2\terror"
@RubenVerborgh
RubenVerborgh / eratosthenes.js
Created July 3, 2016 22:40
Sieve of Eratosthenes with AsyncIterator
var AsyncIterator = require('asynciterator'),
TransformIterator = AsyncIterator.TransformIterator;
function EratosthenesIterator(base) {
TransformIterator.call(this);
base = base || AsyncIterator.range(2);
base.once('data', prime => {
this._push(prime);
this.source = new EratosthenesIterator(base.filter(n => n % prime));
});
@RubenVerborgh
RubenVerborgh / parallel.js
Created April 1, 2016 16:24
Connection rate test
const http = require('http');
const baseUrl = 'http://en.wikipedia.org/wiki/', max = 100;
var index = 1;
(function fetchNext() {
if (index < max) {
var url = baseUrl + index++;
console.log(`fetching ${url}`);
request = http.request(url);