Skip to content

Instantly share code, notes, and snippets.

View justpiple's full-sized avatar
⚠️
Busy

Kusindra Aji Rabbany justpiple

⚠️
Busy
View GitHub Profile
@justpiple
justpiple / qrisConverter.ts
Created March 28, 2025 14:56
QRIS (Quick Response Code Indonesian Standard). Convert Static QRIS to QRIS with nominal information.
export interface QrisSettings {
/** Payment amount (as string number) */
nominal: string;
/** Service fee type: 'p' for percentage, 'r' for fixed value (rupiah) */
feeType?: "p" | "r";
/** Service fee value (as string number) */
feeValue?: string;
}
function padLength(length: number): string {
@justpiple
justpiple / cloudinary.ts
Created March 24, 2025 05:28
A secure and flexible utility for uploading images to Cloudinary using server actions in Next.js.
"use server";
import { v2 as cloudinary } from "cloudinary";
import fs from "fs/promises";
import path from "path";
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME!,
api_key: process.env.CLOUDINARY_API_KEY!,
api_secret: process.env.CLOUDINARY_API_SECRET!,
@justpiple
justpiple / confirmDialog.tsx
Last active March 26, 2025 07:57
A `confirm` dialog component built using ShadCN's UI components.
import React from "react";
import { createRoot } from "react-dom/client";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
@justpiple
justpiple / paginationControls.tsx
Last active January 27, 2025 21:07
A responsive pagination component that adjusts its layout and displayed pages based on the current screen width and total number of pages.
"use client";
import { Button } from "@/components/ui/button";
import { useEffect, useState } from "react";
import {
ChevronFirst,
ChevronLast,
ChevronLeft,
ChevronRight,
} from "lucide-react";
@justpiple
justpiple / driveService.ts
Last active January 17, 2025 02:24
A client for interacting with Google APIs (Sheets and Drive).
import GoogleClient from "./googleClient";
import { drive_v3 } from "googleapis";
/**
* A service for interacting with Google Drive API.
*/
export class DriveService {
/**
* @private
* @type {GoogleClient}
@justpiple
justpiple / bonjourrConfig.json
Created January 9, 2025 02:09
My Bonjourr Config (Chrome Extension)
{
"about": {
"browser": "chrome",
"version": "20.4.1"
},
"showall": true,
"lang": "en",
"dark": "enable",
"favicon": "🔆",
"tabtitle": "New Tab",
@justpiple
justpiple / generatePassword.ts
Created August 8, 2024 13:36
This JavaScript function generates a strong password with customizable length and character inclusion. The password is guaranteed to include at least one uppercase letter, one lowercase letter, one number, and one symbol (if specified).
export function generatePassword(
length: number = 8,
includeUppercase: boolean = true,
includeLowercase: boolean = true,
includeNumbers: boolean = true,
includeSymbols: boolean = true
): string {
const uppercaseCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowercaseCharset = "abcdefghijklmnopqrstuvwxyz";
const numberCharset = "0123456789";
@justpiple
justpiple / abbreviateName.js
Created June 1, 2024 03:05
Abbreviate Name
export function abbreviateName(name) {
let parts = name.split(' ');
// Make 2-letter sentences uncountable
let combinedParts = [];
for (let i = 0; i < parts.length; i++) {
if (parts[i].length <= 2 && i < parts.length - 1) {
combinedParts.push(parts[i] + ' ' + parts[i + 1]);
i++; // Skip 2-letter part
} else {