Skip to content

Instantly share code, notes, and snippets.

@z4vmk
z4vmk / mounting.js
Created May 30, 2023 15:13
Mounting Method SSR
import { useEffect, useState } from "react"
export default function Index(){
const [mounted, setMounted] = useState(false)
useEffect(() => {
setMounted(true)
})
if (!mounted) {
@z4vmk
z4vmk / wifiscan.js
Created March 28, 2024 09:24
HD Example 1
// Dependencies
const express = require("express");
const wifi = require("node-wifi");
// Config
const serverApp = express();
wifi.init({
iface: null,
});
@z4vmk
z4vmk / Dockerfile
Last active September 10, 2024 02:02
(Dockerfile) Bun + Prisma
# Use Linux-Based NodeJS Image as Base
FROM node:latest
# Install OpenSSL Library, required by Prisma
RUN apt-get install libssl3
# Set WorkDir
WORKDIR /app
# Copy Package Files
@z4vmk
z4vmk / TimeConversion.ts
Last active October 9, 2024 03:22
Converts a given number of seconds into a human-readable format of days, hours, minutes, and seconds (e.g., '2d 10h 30m 15s').
function formatTime(seconds: number): string {
if (seconds <= 0) return '0s';
const units: [number, string][] = [
[86400, 'd'],
[3600, 'h'],
[60, 'm'],
[1, 's']
];
@z4vmk
z4vmk / exampleone.ts
Last active October 15, 2024 03:34
HD Example One
// Dependencies
import { hash } from "jsr:@ts-rex/bcrypt";
import { Hono } from "jsr:@hono/hono";
import { encode } from "jsr:@gz/jwt";
// Environment Variables
const DATABASE_URL = Deno.env.get("DATABASE_URL"); // Gets the DatabaseURL from the env.
const JWT_SECRET = Deno.env.get("JWT_SECRET"); // Gets the JWT Secret from the env.
// Create App
@z4vmk
z4vmk / exampletwo.ts
Last active October 15, 2024 03:31
HD Example Two
// Dependencies
import { Hono } from "jsr:@hono/hono";
// Create App
const app = new Hono(); // Creates a new Hono instance.
// Time Conversion Function
// This function converts seconds to a readable time.
// Ex. 312312 = 3d 14h 45m 12s
function formatTime(seconds: number): string {
@z4vmk
z4vmk / examplethree.ts
Created October 15, 2024 03:40
HD Example Three
// Dependencies
import wifi from "npm:node-wifi";
import { Hono } from "jsr:@hono/hono";
// Create App
const app = new Hono(); // Creates a new Hono instance.
wifi.init({
// Initiates the Node Wifi library.
iface: null,
});