Skip to content

Instantly share code, notes, and snippets.

View Deri-Kurniawan's full-sized avatar
:octocat:
Learning, Creating & Sharing

Deri Kurniawan Deri-Kurniawan

:octocat:
Learning, Creating & Sharing
View GitHub Profile
// Hoisting is a condition where javascript seems to move a variable or function to the top of the scope before the code is executed.
// Any variable or function that is called before it is declared should be an error but, that is javascript hoisting, JavaScript seems to move it to the top of the scope before the code is executed.
// Everything is hoisted even if using var, let, const but var will not cause an error, if with let and const it will cause an error and is called a “temporal dead zone” (TDZ). meaning that the new variable can be called after the declaration
// Example 1
console.log(abc); // variable call before it is declared
var abc;
// Example 2
const randHexColor = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
@Deri-Kurniawan
Deri-Kurniawan / CONNECT FTP SERVER.md
Created January 9, 2024 15:15
Connection to a ftp server

Windows

Notation: ftp://@<local_ip_target> Regular Port is 21

use windows explorer and type: ftp://deri@192.168.1.1

@Deri-Kurniawan
Deri-Kurniawan / Javascript Function Collection.js
Last active December 17, 2023 09:02
A collection of Javascript functions to remind us and that we might need
// Get a random number between 1 to max number
function randomNumber(max) {
return Math.floor(Math.random() * max);
}
// Get a random number between min and max number
function randomNumberInRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
<div className="max-w-screen-2xl">
<div className="flex flex-wrap">
{Array.from({ length: 400 })
.fill(0)
.map((_, i) => (
<div
key={i.toString()}
className="animated-item h-16 w-16 rounded-md border-[0.1px] border-black/20 transition-all duration-500 ease-linear hover:bg-primary"
/>
))}
@Deri-Kurniawan
Deri-Kurniawan / MYSQL_CONNECTION_URL_GUIDE.md
Created November 16, 2023 06:15
Guide to creating your mysql connection using URL

Here's a clearer explanation of the structure of the base URL and path with placeholder values, along with implementation examples and an additional example for adding connection timeout:

Base URL Structure:

mysql://USER:PASSWORD@HOST:PORT/DATABASE?KEY1=VALUE&KEY2=VALUE&KEY3=VALUE

Example with Placeholder Values:

import { PrismaClient } from "@prisma/client";
declare global {
var prisma: PrismaClient | undefined;
}
let prisma: PrismaClient;
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient();

https://opengraph.githubassets.com/<any_hash_number>/<owner>/<repo>

example: url: https://opengraph.githubassets.com/og/Deri-Kurniawan/windows-11-os

@Deri-Kurniawan
Deri-Kurniawan / vercel.json
Created August 26, 2023 10:48
Configuration for Deploying Express JS Application on Vercel
{
"version": 2,
"builds": [
{
"src": "src/server.js",
"use": "@vercel/node"
}
],
"routes": [
{
@Deri-Kurniawan
Deri-Kurniawan / cn.ts
Last active November 21, 2023 13:41
Tailwindcss class merger function
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}