Skip to content

Instantly share code, notes, and snippets.

@mustofa-id
mustofa-id / download_quran_audio.js
Last active April 12, 2024 01:33
Script to download Quran audio
import { createWriteStream, existsSync, mkdirSync } from "fs";
import { join } from "path";
import { pipeline } from "stream/promises";
/**
* To get `qari_dir`:
* 1. Go to https://quranicaudio.com
* 2. Choose qari
* 3. Hover to the download button, you will see the download link contains qari directory
*
const total = 1_000;
const limit = 40;
const messages = [];
let ok = 0;
let fail = 0;
async function send() {
try {
// copy from chrome dev-tools
@mustofa-id
mustofa-id / util.ts
Created June 24, 2023 02:09
Node postgres (pg) template string
import type { CustomTypesConfig, QueryConfig } from 'pg';
export class Template_Query_Config implements QueryConfig {
private name_?: string;
private types_?: CustomTypesConfig;
constructor(private readonly strings: string[], readonly values: any[]) {}
get text(): string {
return (
@mustofa-id
mustofa-id / check-link.mjs
Created April 5, 2023 03:15
Find valid Telegram Group invite link. This is a challenge from my friend.
@mustofa-id
mustofa-id / AudioPlayer.js
Created July 1, 2021 06:27
Nodejs play audio file using available player
import { spawn } from "child_process";
import { readdirSync } from "fs";
import path from "path";
class AudioPlayer {
constructor({ player, folder, ext = "wav" }) {
if (!player || !folder) throw new Error(`Parameters 'player' and 'folder' are required`)
this.player = player;
this.folder = path.resolve(folder);
this.ext = `.${ext}`;
@mustofa-id
mustofa-id / JTableLoader.java
Last active July 13, 2022 12:15
Loader for easily load list to JTable (Java Swing).
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
@mustofa-id
mustofa-id / Bicycle.dart
Last active January 24, 2019 07:33
Learn dart language as Java Developers
class Bicycle {
int cadence;
int _speed = 0; // Private
int gear;
Bicycle(this.cadence, this.gear);
int get speed => _speed; // Getter
void applyBreake(int dec) {
@mustofa-id
mustofa-id / fish_prompt.fish
Created January 19, 2019 04:06
JavaScript object style for fish-shell prompt
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
set -l _ob (set_color yellow)'{ '(set_color normal)
set -l _cb (set_color yellow)' }'(set_color normal)
set -l _c1 "┏┈$_ob"
# User
set -l _usr (set_color cyan)'usr: '(set_color green)'\'hm\''(set_color normal)', '
@mustofa-id
mustofa-id / guid.js
Created December 26, 2018 03:04
Generate random GUID using JavaScript
// Generate random GUID
function guid() {
const rand = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
let res = rand();
for (let i = 0; i < 11; i++) {
i % 2 && i <= 7 ? (res += '-') : (res += rand());
}
return res;
}
@mustofa-id
mustofa-id / JSimpleTableModel.java
Created May 27, 2018 05:36
Swing JTable model with generic parameter
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
/**
* @param <T> entity class