Skip to content

Instantly share code, notes, and snippets.

View it16knitto's full-sized avatar

Ilham Firdaus Knitto it16knitto

View GitHub Profile
@it16knitto
it16knitto / helperFormat.ts
Created November 8, 2024 09:10
Format replace object key to caption (node js)
export const formatToCaption = (value: string) => {
return value
.replace('OpenB_', '(')
.replace('_CloseB', ')')
.replace('_PeR', '/')
.replace('_DaSh', ' -')
.split('_')
.map((word) => {
import { headerRatioPenJualanRollanKGan } from '@/app/http/laporan/reordering/ratio-penjualan-rollan-kgan/ratio-penjualan-rollan-kgan.header';
import ExcelJS from 'exceljs';
import * as fs from 'fs';
// Define types for columns and data
interface Column {
header: string;
key: string;
width: number;
type?: string;
}
@it16knitto
it16knitto / cabang-service-index.js
Last active November 13, 2024 09:23
simple saga pattern with axios and mysql and use express
// cabang-service/index.js
const express = require('express');
const mysql = require('mysql2/promise');
const app = express();
app.use(express.json());
const db = mysql.createPool({
host: 'localhost',
user: 'root',
export const groupByFromArray = (data: any[]) => {
const grouped = {};
// Iterasi setiap objek dalam JSON array menggunakan for...of
for (const obj of data) {
// Iterasi setiap key-value dalam objek
for (const [key, value] of Object.entries(obj)) {
if (!grouped[key]) {
grouped[key] = new Set(); // Gunakan Set untuk memastikan nilai unik
}