Skip to content

Instantly share code, notes, and snippets.

View bitnom's full-sized avatar
💭
forever building

bitnom bitnom

💭
forever building
View GitHub Profile
@bitnom
bitnom / setu.js
Created July 25, 2019 15:57
gun setu() - add to set only if unique
function setu(node, item){
let unique = true
let comparison = function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if ((aProps.length-1) === bProps.length) {
for (let i = 1; i < aProps.length; i++) {
let propName = aProps[i];
// values of same property
@bitnom
bitnom / recall.js
Created July 19, 2019 15:26
Gun User Recall
user.recall(6 * 60, { // minutes
session: true,
hook: function(props) { // { iat, exp, remember }
console.log("got to hook")
var passed = (Time.now() / 1000) - props.iat; // seconds internally
return (passed < exp) ? ((props.exp += passed) && props) : props;
}
}).then(function(ack) {
console.log("got to then")
if (ack && ack.sea) {
@bitnom
bitnom / setu.js
Created July 18, 2019 15:24
gun set if unique (Working)
function setu(node, item){
let unique = true
node.map().once(function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if ((aProps.length-1) === bProps.length) {
for (let i = 1; i < aProps.length; i++) {
let propName = aProps[i];
// values of same property
@bitnom
bitnom / setu.js
Created July 18, 2019 15:00
set if unique
function setu(node, item){
let unique = true
node.map().once(function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if (aProps.length === bProps.length) {
console.log("same len")
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];
@bitnom
bitnom / gununique.js
Created July 18, 2019 14:37
gun unique
function isu(node, item){
node.map().once(function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if (aProps.length === bProps.length) {
console.log("same len")
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];
// values of same property
@bitnom
bitnom / sdp1.json
Created July 9, 2019 00:52
SDP-experiment-1
#offer was created
{"type":"offer","sdp":"v=0\r\no=- 1757076532130201660 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:ayhN\r\na=ice-pwd:wSlLKaiyFy9Z3I+YBq0JbDf6\r\na=ice-options:trickle\r\na=fingerprint:sha-256 B2:93:08:8A:C5:49:1D:B4:53:1E:00:B4:ED:48:2A:03:8C:77:6E:BA:A8:52:3D:B1:EB:0D:CA:43:6F:B1:08:0D\r\na=setup:actpass\r\na=mid:0\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"}
#response was sent
{"type":"answer","sdp":"v=0\r\no=- 8436459379733692345 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:aaRr\r\na=ice-pwd:k4O6SwMSygQOf1zTh/W1YG3S\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F6:DE:8C:08:E5:1A:EB:8E:50:16:C4:2C:CC:AD:A8:B3:8A:35:2A:4C:BB:1E:99:19:03:0E:FE:B7:06:88:C9:75\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\n"}
# No public IP in any of that? Some
@bitnom
bitnom / node-pre-gyp_error.log.txt
Created July 8, 2019 02:09
node-pre-gyp full log
0 info it worked if it ends with ok
1 verbose cli [ '/home/user/.nvm/versions/node/v11.6.0/bin/node',
1 verbose cli '/home/user/.nvm/versions/node/v11.6.0/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'webcat' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 5b5ab164cf613802
5 silly install loadCurrentTree
@bitnom
bitnom / superNode.js
Last active January 28, 2021 08:58
Troubleshooting Gun localStorage
const path = require('path');
const express = require('express');
var fs = require('fs')
var https = require('https')
var http = require('http')
const Gun = require('gun');
const SEA = require("gun/sea");
require("gun/lib/webrtc");
const port = (process.env.PORT || 8080);
@bitnom
bitnom / combo.js
Created July 7, 2019 00:41
Gun HTTP/HTTPS experiment
const path = require('path');
const express = require('express');
var fs = require('fs')
var https = require('https')
var http = require('http')
const Gun = require('gun');
const SEA = require("gun/sea");
require("gun/lib/webrtc");
const port = (process.env.PORT || 8080);
@bitnom
bitnom / gundbfileErr.txt
Created July 7, 2019 00:40
Gun db as file error
SSL Peers:
Peers:
in msg:{"put":{"tom":{"_":{"#":"tom",">":{"name":1562445284408,"occupation":1562445284408}},"name":"tom","occupation":"engineer"}},"#":"4vacfvlnv9v","##":-2111997827}.........
out msg:{"put":{"tom":{"_":{"#":"tom",">":{"name":1562445284408,"occupation":1562445284408}},"name":"tom","occupation":"engineer"}},"#":"4vacfvlnv9v","##":-2111997827}.........
in msg:{"@":"4vacfvlnv9v","err":null,"ok":1,"#":"sswJgBuXP"}.........
out msg:{"@":"4vacfvlnv9v","err":null,"ok":1,"#":"sswJgBuXP"}.........
SSL Peers: lfvsmsoIa
Peers:
ERROR: { [Error: ENOTDIR: not a directory, open '/home/site/public_html/test/superPeer/localBase/thedb/%1C']
errno: -20,