Skip to content

Instantly share code, notes, and snippets.

View ThinkingJoules's full-sized avatar

Julian Stahl ThinkingJoules

  • Denver, CO
View GitHub Profile
mesh.hear = function(raw, peer){
if(!raw){ return }
var msg, id, hash, tmp = raw[0];
if(opt.pack <= raw.length){ return mesh.say({dam: '!', err: "Message too big!"}, peer) }
try{msg = msg || decode(raw);
}catch(e){return opt.log('DAM JSON parse error', e)}
if(msg && Array.isArray(msg)){
var i = 0, m;
while(m = msg[i++]){
mesh.hear(m, peer);
@ThinkingJoules
ThinkingJoules / EULA.md
Created September 13, 2019 16:07
EULA QBO APP

This app provides no guarantees. Use at your own risk. Any data loss or leaks are not our responsibility even if it was due to using this app.

function getList(idxSoul,cb){
let listOfSouls = {}
let soulsToCheckAgainstUnique = []
gun.get(idxSoul).once(function(data){
if(data === undefined){cb.call(cb,listOfSouls); return}//for loop would error if not stopped
for (const soul in data) {
if(soul === '_')continue
if(data[soul] !== null){//not Deleted
//this means `false` will pass through, so archived items will still keep increment and unique values enforced
soulsToCheckAgainstUnique.push(soul)
@ThinkingJoules
ThinkingJoules / GundbSampleServer--server.js
Last active October 16, 2020 15:13
Basic express + Gun setup
const path = require('path');
const express = require('express');
const Gun = require('gun');
require('gun/nts')
const port = (process.env.PORT || 8080);
const app = express();
app.use(Gun.serve);
@ThinkingJoules
ThinkingJoules / GunDBpermissionExample.js
Created April 25, 2019 15:29
GunDB group permissions example. Restrict reads and/or writes.
//CLIENT
Gun.on('opt', function (ctx) {
if (ctx.once) {
return
}
this.to.next(ctx)
ctx.on('auth', function(msg){
let to = this.to
clientAuth(ctx)
function clientAuth(ctx){