Skip to content

Instantly share code, notes, and snippets.

View RangerMauve's full-sized avatar
💜
Decentralizing

Mauve Signweaver RangerMauve

💜
Decentralizing
View GitHub Profile
WebRTC, unlike Dat, requires doing a handshake through a third party.
With beaker, that third party can be the existing P2P connections that you have.
To connect between two peers you need to do the following:
- Create a Dat Archive for the call website
- Listen on messages in the [dat-peers API](https://beakerbrowser.com/docs/apis/experimental-datpeers)
- Have the user enter a "room"
- Set up the WebRTC connection, send the SDP handshake and the `room` through datPeers
- When you get messages for your room, pass them to the local PeerConnection as being remote SDP or ICE
@RangerMauve
RangerMauve / dat-sdk.md
Last active April 9, 2019 23:10
Tools in the Dat Toolbelt

Dat Toolbelt

Dat has a cool ecosystem with a bunch of different people working on interesting things. This is a list of what I'd like to have in an official Dat Toolbelt along with tutorials on how to use these tools.

Data

  • Files
    • Create a file, share it with a dat:// link
  • All archives should be multiwritable, with mounts / etc
@RangerMauve
RangerMauve / dirty-dat-fetch.js
Last active October 26, 2018 20:12
Patch `window.fetch` to support dat:// URLs
window._fetch = fetch
window.fetch = async function(url) {
if(url.startsWith("dat://")) {
const parsed = new URL(url)
const archive = await DatArchive.load(`dat://${parsed.hostname}`)
return {
text: async () => {
return archive.readFile(parsed.path, "utf8")
}
}
@RangerMauve
RangerMauve / clink_prompt.lua
Last active April 8, 2020 03:30
Clink script for having a nice command prompt with git branch support and home directory aliasing
@RangerMauve
RangerMauve / ostrum-lang.md
Created March 29, 2016 02:19
Ideas for programming language

Ostrum

A simple, lisp-like, and functional language for experimenting with making a language.

Variable declarations

Variables are declared on the stack, declaring one can be done with the = function. Variables are marked as being constant upon being assigned, and cannot be reassigned again within the current function. The assignment function takes two arguments, name:String and value:Any. Since it's just a function, you can pass in a variable for the name to have dynamically resolved names within the current scope.

Assigning to a variable example:

@RangerMauve
RangerMauve / mqtt.pegjs
Created March 21, 2016 21:56
MQTT-Regex parser in PEG.js
path = items:(pathStart pathEnd?) {return items[0].concat(items[1])}
pathStart = (items:(pathItem / singleParam / single)+)
pathEnd = item:(multiParam / multi / lastItem) {return item}
pathItem = text:pathName "/" {return {type: "text", content: text}}
lastItem = text:pathName "/"?
@RangerMauve
RangerMauve / example.s
Created March 21, 2016 21:55
S Expressions in PEG.js
(
(
[] 1337 "cats" dogs)
(+ 1 0xFF)
)
conspicor (Behold) -> Observable library
nexilis (Tied) -> Templating library
@RangerMauve
RangerMauve / index.js
Created April 29, 2015 14:58
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var Ractive = require("ractive");
var Swipe = require("ractive-swipe-pages");
var ractive = new Ractive({
el: '#container',
template: '#template',
data: {
toggled: true
@RangerMauve
RangerMauve / gist:3628bed7a25cd79a6394
Created January 19, 2015 22:26
Facade duplex streams
//https://www.npmjs.com/package/duplexer
var duplexer = require("duplexer");
var through = require("through2");
function boostrap(fn){
var input = noop(); // Just passes data through
var output = noop(); // Just passed data through;
input.once("data",function(chunk, encoding, cb){