Skip to content

Instantly share code, notes, and snippets.

@davidmaxwaterman
davidmaxwaterman / gun-panic-notes.md
Last active January 25, 2023 21:27
Notes on writing end-to-end tests with gun's panic server/client.

The docs on Gun's Panic are written from the point of view of someone testing Gun itself, rather than an app that uses Gun. As such it isn't very helpful in how to get started, and the tests aren't all that applicable. So, I figured I'd share my findings after building Panic tests for my app.

refs:

NB, in my case, I was using Gun in an extension, so my 'app' is quite well separated from the panic server. Most people will be testing Gun in a regular web page, so it might be simpler.

  1. in the project you want to test, install dev dependency gun-server: npm install --save-dev panic-server
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>capture microphone audio into buffer</title>
</head>
<body>
<audio id="player" controls></audio>
<input
type="text"
id="username"
// WARNING: There's much more to know/do around hooks, and
// this is just a simplification of how these work.
// shared references, updated
// per each hook invoke
let execution = null;
let current = null;
let context = null;
let args = null;
@alterx
alterx / graph.js
Last active April 11, 2021 21:04
GunDB useful resources
// Dletta has implemented a depth-first (and sort of breadth-first) search algorithm for gun graphs.
var stack;
var nodes;
var edges;
var start;
var u;
var label;
var opt = true;
@apiraino
apiraino / AuthService.php
Last active March 31, 2020 19:09
Simple static token authentication with Directus API
<?php
declare(strict_types=1);
use Directus\Services\AuthService as DirectusAuthService;
use Directus\Authentication\Exception\UserNotFoundException;
class AuthService
{
private function getToken($req)
@0xhexmex
0xhexmex / Static python executable.txt
Last active December 1, 2023 14:50
How to turn a python script into a statically linked executable with pyinstaller and staticx
// Example below is with mitm6 (https://github.com/fox-it/mitm6/)
// Note: Adding the '--add-binary' option here is specific to mitm6, not required in all cases.
# pip install pyinstaller
# pyinstaller --clean -F --add-binary="/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0:." ./mitm6.py
// The step above will create a single binary in the ./dist/ directory called mitm6
// Install staticx and dependencies
@Jonarod
Jonarod / Service_Workers_Messaging.md
Last active January 3, 2024 19:16
Describes how to send messages between a page's main thread and a service worker thread

Page to ServiceWorker

// in page.html
navigator.serviceWorker.controller.postMessage({'hello':'world'});
// in sw.js
self.addEventListener('message', event => { 
@Dletta
Dletta / index.html
Created September 7, 2019 03:37
Gun in Service Worker
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Concept Chat</title>
<link rel="stylesheet" href="index.css" >
</head>
<body>
// The core app code
var myApp = (function () {
'use strict';
// Create a public methods object
var methods = {};
/**
* Extend the public methods object
@ibuildthecloud
ibuildthecloud / README.md
Last active April 2, 2024 19:02
k3s on WSL2

Instructions to hack up WSL2 on Windows 10 Build 18917 to run k3s (Kubernetes) and rio

Install WSL2

https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

I already had Ubuntu-18.04 installed in wsl 1. So I just did wsl --set-version Ubuntu-18.04 2

Compile Kernel

Using Ubuntu 18.04 (I'm sure any distro will work), inside WSL2 download https://thirdpartysource.microsoft.com/download/Windows%20Subsystem%20for%20Linux%20v2/May%202019/WSLv2-Linux-Kernel-master.zip and extract to a folder. The latest version of the kernel source is available at (https://github.com/microsoft/WSL2-Linux-Kernel)