Skip to content

Instantly share code, notes, and snippets.

View Viiprogrammer's full-sized avatar
🤩
Working hard on Opengram

Maksim Viiprogrammer

🤩
Working hard on Opengram
View GitHub Profile
@Viiprogrammer
Viiprogrammer / swagger-hot-reload.js
Created October 8, 2024 23:13
Swagger auto hot reload
function waitForElement (selector, timeout) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector))
}
// eslint-disable-next-line no-undef
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect()
@Viiprogrammer
Viiprogrammer / index.js
Last active March 2, 2025 23:29
Infinite SSH tunnel
const { spawn } = require('node:child_process');
const user = 'user'
const password = 'password'
const ip = '1.1.1.1'
const port = 5173
let sshCommand = `-p ${password} ssh `
sshCommand += '-o ServerAliveInterval=5 '
sshCommand += `${user}@${ip} `
@Viiprogrammer
Viiprogrammer / docusaurus-mermaid.md
Last active February 12, 2023 11:52
docusaurus-mermaid

I couldn't find any solution to use Mermaid without changing the theme to @docusaurus/theme-mermaid and trying to write a solution, and... it works great.

Create mermaid.js in /src/js/ and use it in MDX as below

(Don't forget remove .example extension from example.mdx.example)

import React, { useEffect } from 'react'
import { useColorMode } from '@docusaurus/theme-common';
import mermaid from "mermaid";
mermaid.initialize({
startOnLoad: true,
theme: 'neutral'
});
const Mermaid = ({ chart }) => {
var types = {
'339966': 'voicer',
'00a650': 'voicer',
'800000': 'techie',
'ebd800': 'translator',
'f7941d': 'decorator',
'000080': 'seeder',
'b523c5': 'releaser',
'33cccc': 'designer'
}