Skip to content

Instantly share code, notes, and snippets.

View bmatusiak's full-sized avatar
👌
Having Fun

Bradley Matusiak bmatusiak

👌
Having Fun
View GitHub Profile
function emptyLoad(target){
function lookup(){
if (ready) ready = false;
target.once((data) => {
if (data) {
clearInterval(checkInterval);
}else{
ready = true;
lookup()
}
@bmatusiak
bmatusiak / uds.js
Last active August 30, 2023 11:19
gun uds Unix_domain_socket
const net = require('net');
const path = require('path');
const fs = require('fs');
var listen_path = path.join(process.cwd(), 'gun_sockets');
if (!fs.existsSync(listen_path)) {
fs.mkdirSync(listen_path);
}
listen_path = path.join(listen_path, 'gun.socket');
@bmatusiak
bmatusiak / basic-uds-net.js
Created August 29, 2023 20:25
basic-uds-net.js
const net = require('net');
const path = require('path');
var listen_path = path.join(process.cwd(), 'nodejs.socket');
if (process.platform.indexOf("win") > -1)
listen_path = path.join('\\\\?\\pipe', process.cwd(), 'nodejs.socket');
module.exports = {
server: function () {
@bmatusiak
bmatusiak / DynamoDB.js
Last active August 26, 2023 16:36
gun DynamoDB store
var Gun = require('gun/gun');
Gun.on('create', function lg(root) {
this.to.next(root);
const CyclicDb = require("@cyclic.sh/dynamodb")
const db = CyclicDb(process.env.CYCLIC_DB);
const COLLECTION = "gun2";
const collection = db.collection(COLLECTION);
@bmatusiak
bmatusiak / s3.js
Created August 25, 2023 13:30
s3 js-v3
const s3_bucket = process.env.AWS_BUCKET;
const s3_region = process.env.AWS_REGION;
(async function () {
const {
S3Client,
ListObjectsCommand,
GetObjectCommand,
PutObjectCommand,
@bmatusiak
bmatusiak / 1243.js
Last active May 31, 2022 04:48 — forked from draeder/1243.js
Gun Heroku one-click deploy testing
/**
* NOTE: Does not work with npm installed heroku-cli
*
* Heroku CLI REQUIRED! Uninstall with: npm uninstall heroku -g
* Install Heroku with: curl https://cli-assets.heroku.com/install.sh | sh
* Login Heroku with: heroku login
*
* after login you can run test
* like: $ mocha test/bug/1243.js
*
module.exports = function(gun) {
function $gun(last) {
var self = this;
if (last) {
self.last = last;
self.root = last.root;
}
else {
self.user = function(user) {
var _user = new $gun();
module.exports = function(pwd, extra) {
var forge = require("node-forge");
forge.options.usePureJavaScript = true;
var EC = require('elliptic').ec;
return new Promise((resolve, reject) => {
var ec_p256 = new EC('p256');
if (!pwd)
#ifdef USE_ECDH
#include "mbedtls/include/mbedtls/ecdh.h"
static NO_INLINE JsVar *jswrap_crypto_ecdh(JsVar *message, JsVar *key, JsVar *options, bool genSecret ) {
int ret;
JSV_GET_AS_CHAR_ARRAY(msgPtr, msgLen, message);
if (!msgPtr) return 0;
mbedtls_ecdh_context ecdh_ctx;
var net = require('net');
var fs = require('fs');
var SSH_AUTH_SOCK_PATH_PREFIX = "/tmp/ssh-agent."
var SSH_AUTH_SOCK_PATH_POSTFIX = ".sock"
function createServer(socketName, callback, onConnect) {
var SSH_AUTH_SOCK_PATH = SSH_AUTH_SOCK_PATH_PREFIX + socketName + SSH_AUTH_SOCK_PATH_POSTFIX;