Skip to content

Instantly share code, notes, and snippets.

View andirkh's full-sized avatar
💪
do our very best to produce software we can be proud of

Andi R. Hermawan andirkh

💪
do our very best to produce software we can be proud of
  • East Java, Indonesia
View GitHub Profile
const fs = require('fs');
const path = require('path');
// Define the directory containing the SVG files
const svgDirectory = './flags';
function dashedToCamelCase(input) {
return input.replace(/-([a-z])/g, function(match, letter) {
return letter.toUpperCase();
});
@andirkh
andirkh / redux-like.html
Last active February 23, 2024 06:37
redux-like-static-html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Redux-like State Management</title>
</head>
<body>
<button id="updateButton" onclick="actionUpdateButton()">Update State</button>
@andirkh
andirkh / redundant.js
Created February 23, 2024 03:47
Redundant Script Remover
const Interaction = (id) => {
return `
<div class="interactive-section" id="interactive-section-${id}">
<button class="click-me-button" onclick="displayMessage(${id})">Click Me!</button>
<p class="output-message"></p>
</div>
<script>
function displayMessage(id) {
const outputMessage = document.querySelector('#interactive-section-' + id + ' .output-message');
@andirkh
andirkh / shell.nix
Created February 17, 2024 13:55 — forked from glendmaatita/shell.nix
OnXP Python Web Development
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11";
pkgs = import nixpkgs { config = { allowUnfree = true; }; overlays = []; };
git = pkgs.git.overrideAttrs (oldAttrs: rec {
version = "2.42.0";
});
podman = pkgs.podman.overrideAttrs (oldAttrs: rec {
version = "4.7.2";
@andirkh
andirkh / lastxdays.js
Created July 25, 2023 05:18
get last x days
const getLastDays = (day) => Array.from({ length: day }, (_, i) => new Date(Date.now() - i * 24 * 60 * 60 * 1000));
label {
margin-bottom: 0.5rem;
}
@andirkh
andirkh / cut_gamelan_by_onset.py
Created February 8, 2022 08:10
Cut gamelan sound by their onsets
from pydub import AudioSegment
import uuid
import librosa
import numpy as np
import os
BASE_FOLDER = './dir/'
FILE = 'Saron_mono_1.wav'
file_path = os.path.join(BASE_FOLDER, FILE)
@andirkh
andirkh / convert_stereo_mono.py
Created February 8, 2022 06:16
Convert Stereo to Mono
import os
from pydub import AudioSegment
DIRECTORY = './your_directory'
LIST_DIR = os.listdir(DIRECTORY)
for filename in sorted(LIST_DIR):
if filename.endswith('.wav'):
sound = AudioSegment.from_wav(DIRECTORY + "/" + filename)
sound = sound.set_channels(1)
@andirkh
andirkh / container.template.js
Last active March 31, 2021 07:08
Minimum Viable Unit Test for React Container/Component
import React from 'react';
import { shallow } from 'enzyme';
import ContainerName from '#containers/ContainerName';
describe('<ContainerName />', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<ContainerName />);
});
afterEach(() => {
@andirkh
andirkh / selectors.template.js
Last active March 27, 2021 22:51
Template for testing selectors
import { fromJS } from 'immutable';
import {
...
} from '#src/containers/ContainersName/selectors';
import { initialState } from '#src/containers/ContainersName/reducer';
let mockReduxData;
jest.mock('reselect', () => ({
createSelector: (fn, fn2) => {