Skip to content

Instantly share code, notes, and snippets.

View thoriqmacto's full-sized avatar
🎯
Focusing

Thariq thoriqmacto

🎯
Focusing
View GitHub Profile
@thoriqmacto
thoriqmacto / custom-block-variation.js
Created April 17, 2024 11:17
Wordpress block variation registration code for post-featured-image to include caption automatically.
// Define the custom block variation
wp.blocks.registerBlockVariation(
'core/post-featured-image', // Base block type
{
name: 'sotp/post-featured-image', // Variation name
title: 'Post Featured Image + Caption', // Variation title
description: 'Displays the post\'s featured image with caption.', // Variation description
attributes: {
namespace: 'sotp_post_featured_image', // Custom attribute namespace
className: 'sotp-post-featured-image' // Custom class name
@thoriqmacto
thoriqmacto / wpessential_filter_hooks.php
Created April 17, 2024 11:15
Implement essential admin hooks settings features for WordPress.
<?php
/**
* Plugin Name: WP Essential Filter Hooks
* Description: Implement essential admin hooks settings features for WordPress.
* Version: 1.0
* Author: macto
*/
// Add "Duplicate" Button for Pages and Posts
function custom_duplicate_button($actions, $post) {
@thoriqmacto
thoriqmacto / GenerateChecksheetByLoop.bas
Created January 30, 2024 06:16
Sub-routine to generate checksheet associated with the loop in new sheet. There is lookup table that consist of all information for loop to checksheets relationship.
Sub GenerateChecksheetByLoop()
' Define the source worksheet
Dim sourceSheet As Worksheet
Set sourceSheet = ActiveSheet ' You can change this to the specific sheet
' Define the selected range
Dim selectedRange As Range
On Error Resume Next
Set selectedRange = Application.InputBox("Select the range containing Loop Name and Count", Type:=8)
On Error GoTo 0
@thoriqmacto
thoriqmacto / ExportTableToPipeSeparated.bas
Last active December 9, 2023 15:12
VBA code that loops through an Excel table and generates list separated by "|" statements based on the data.
Sub ExportTableToPipeSeparated()
Dim wb As Workbook
Set wb = ThisWorkbook
Dim ws As Worksheet
Dim wsName As String
wsName = "your_worksheet_name" 'Replace with your sheet name
Set ws = wb.Sheets(wsName)
ws.Select
@thoriqmacto
thoriqmacto / ExportTableToSQL.bas
Last active December 5, 2023 15:30
VBA code that loops through an Excel table and generates SQL INSERT statements based on the data
Sub ExportTableToSQL()
Dim wb As Workbook
Set wb = ThisWorkbook
Dim ws As Worksheet
Dim wsName As String
wsName = "your_worksheet_name" 'Replace with your sheet name
Set ws = wb.Sheets(wsName)
ws.Select
@thoriqmacto
thoriqmacto / .gitignore
Created November 15, 2023 15:38
.gitignore template for ideaProject
# IDE related files
.idea/
*.iml
*.iws
*.ipr
# Build output
out/
target/
build/
@thoriqmacto
thoriqmacto / node_cmd_in_windows_powershell.js
Last active August 1, 2023 14:06
Compilations of node commands in windows powershell terminal.
// To set NODE_ENV to some variables
$env:NODE_ENV="production"
// To run node server with NODE_DEBUG
$env:NODE_DEBUG="server";node index.js
@thoriqmacto
thoriqmacto / audioviz_overlay.sh
Last active June 18, 2022 14:53
Script to run FFMPEG overlay audio-viz to picture.
#! /bin/sh
ifn="[slug_name]"
pref="`basename $0 .sh`"
fpathaudio="in/${ifn}.mp3"
fpathpic="in/${ifn}.jpg"
# RUN FFMPEG SCRIPT
./ffmpeg -y -i "${fpathaudio}" -i "${fpathpic}" -filter_complex "
[0:a]showwaves=s=640x150:mode=cline:colors=red,colorkey=0x000000:0.01:0.1,format=yuva420p[v];
@thoriqmacto
thoriqmacto / DockerLaravelSetupNotes.md
Last active May 19, 2024 11:47
[Docker] Setup Docker Environment for Fresh Laravel Web Project

Courtesy

This notes is simplify version of long series of Docker Setup for local web development project write by tech.osteel.me. Adjustments were made based on my habit and repetitive step when starting new laravel new project.

Preparation

  1. Ensure Docker Desktop with Docker Compose has been installed.
  2. Create project folder (for example: /Users/macto/Development/laravel-project).
  3. Change project name inside this notes with yours.
    • For folder: laravel-project.
    • For inside config files: laravelproject.
  4. In this notes I use only below services:
@thoriqmacto
thoriqmacto / IsArrayUnique.bas
Created January 13, 2021 07:43
[VBA] Boolean function to return whether a 1D-array members is unique or not.
Public Function IsArrayUnique(tArr As Variant) As Boolean
Dim out As Boolean, tOut As Double
Dim i As Long
For Each t In tArr
If Len(t) > 0 Then
tOut = WorksheetFunction.Match(CStr(t), tArr, 0)
If WorksheetFunction.IsError(tOut) Then
out = False
Else