Skip to content

Instantly share code, notes, and snippets.

@hivelogic2018
hivelogic2018 / argon2.js
Created September 28, 2025 04:32
hashing with argon2.js
const argon2 = require('argon2');
const readline = require('readline');
async function hashPassword() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const password = await new Promise(resolve => {
@hivelogic2018
hivelogic2018 / Git.md
Created September 5, 2025 11:03
Git SSH

If I have multiple ~/.ssh key pairs for connecting to Github ([email protected]:hivelogic2018/nuxt-vuetify-simple.git), Gitlab and I just generated new pair for Forgejo. How does eval $(ssh-agent -s) and ssh-add ~/.ssh/id_forgejo_rsa do? How to keep them together in sync for different git servers? with ssh-add ? without having to keep switching among ssh-agent(s) ?

eval $(ssh-agent -s) and ssh-add ~/.ssh/id_forgejo_rsa are the two key commands for managing SSH authentication with an SSH agent.

ssh-agent is a program that runs in the background and holds your private SSH keys in memory. This is a secure way to manage your keys, especially those with passphrases, since it prevents you from having to enter the passphrase every time you connect to a server. When you run eval $(ssh-agent -s), you're starting this program and setting environment variables (SSH_AUTH_SOCK and SSH_AGENT_PID) in your current shell session so that other SSH programs know where to find the running agent.

ssh-add is the comm

@hivelogic2018
hivelogic2018 / dbgate.md
Last active September 5, 2025 08:15
DBGate MongoDB support

how is dbgate supporting mongodb? limited?

DbGate provides robust and comprehensive support for MongoDB, using the native MongoDB driver to ensure full functionality. Its support is not limited and is designed to handle key NoSQL concepts.

Here are some of the key features that demonstrate how DbGate supports MongoDB:

  • Data Browsing and Editing: You can browse collection data in both a table-like view and a native JSON view. This allows for easy filtering, sorting, and editing of data.
  • Querying: DbGate has a dedicated query console for MongoDB where you can execute queries using Node.js MongoDB API syntax. This goes beyond a simple find and allows for complex operations.
  • Import and Export: DbGate allows you to import and export data from MongoDB collections in multiple formats, including JSON, CSV, and Excel.
  • Advanced Features: It includes a visual query designer that can even join data between MongoDB collections and traditional SQL tables, which is a unique and powerf
@hivelogic2018
hivelogic2018 / ask.md
Created September 5, 2025 06:22
PHP sites
# nginx for PHP service

nginx:

image: nginx:alpine

container_name: nginx

restart: on-failure:3
@hivelogic2018
hivelogic2018 / unix.md
Last active August 30, 2025 16:47
chmod & chown

Give execute and read permissions to the owner (and group) for both files

chmod u+x start-infra.sh
chmod u+x firewall_rules.sh

Change ownership of the files to the user and group that will run the script

Replace 'youruser' and 'yourgroup' with the actual user and group

chown youruser:yourgroup start-infra.sh
chown youruser:yourgroup firewall_rules.sh

To find your username and primary group for the chown command on an Ubuntu server, you can use these simple commands:

@hivelogic2018
hivelogic2018 / compose.yaml
Created August 30, 2025 03:38
Alpine-admin-box
# Alpine Admin/Tools Box
alpine-admin-box:
image: debian:stable-slim # A small image with git and basic tools
container_name: alpine-admin-box
env_file:
- /etc/infra.env
networks:
- infra_net
# You might want to keep it running for interactive use
restart: unless-stopped # Or 'unless-stopped' if you want it persistent
@hivelogic2018
hivelogic2018 / SSH TCP Ports.md
Last active September 5, 2025 11:24
Wireguard (WG-Easy)

I thought the port 3024 is simply enough

sudo ufw allow 3024/tcp # the ssh tunnel for Forgejo users' code commits

sudo ufw allow 2222/tcp # for Forgejo:Git SSH access via port 2222

The reason you need to open both port 3024 and 2222 is that they serve two distinct purposes in your Teleport and Forgejo setup.

Port 3024: The Reverse Tunnel 🚇

is traefik_dynamic.yaml usually needed? while I already have command: --trusted-origins docker.infra.zingastay.com

traefik_dynamic.yaml

http:

serversTransports:

@hivelogic2018
hivelogic2018 / q&a.md
Last active August 23, 2025 07:10
MongoDBConnection

I have my db connection object for instantiation like this. Looks like a factory design for db connection pool establishing. Going through my code files, analyze, explain to me about them and its implementation. How to use db connection class and use it together with DTO/? Also, analyze and explain how effective/redundant it is. Also, in Mongodb, is it necessary and required to perform dbConnection.close() often? how often? Advise me on best practices to streamline my development


Let’s dive into your codebase, analyzing the provided files, explaining their implementation, and addressing your questions about the MongoDBConnection class, its integration with DTOs, its effectiveness, the necessity of closing MongoDB connections, and best practices for streamlining development. I’ll also evaluate the design patterns and suggest improvements for efficiency and clarity.


Analysis of Provided Files

@hivelogic2018
hivelogic2018 / traefik-vs-caddy.md
Created August 21, 2025 17:47
Traefik advantage

explain traefik dynamic service discovery ? meaning working with docker services, I don't need to restart traefik container? fair to say, essentially, changes of labels for portainer, forgejo services, don't require a restart on traefik? any other benefits traefik dynamic service discovery offers besides that?

Yes, it is fair to say that with Traefik's dynamic service discovery, you don't need to restart the Traefik container when you add, remove, or change labels on other Docker services like Portainer or Forgejo. This is a core feature that makes it a "cloud-native" reverse proxy.

How It Works

Traefik works by acting as a proxy and a watcher. 🧐 It connects to the Docker API and constantly monitors for changes in the container's state. When you start, stop, or update a container with the appropriate Traefik labels, Docker emits an event. Traefik listens for these events and instantly reconfigures itself in memory without needing a restart. It reads the labels from the new or changed container