Skip to content

Instantly share code, notes, and snippets.

View kidino's full-sized avatar

Iszuddin Ismail kidino

View GitHub Profile
@kidino
kidino / functions.php
Created April 15, 2025 12:16
WooCommerce Add-to-Cart & Empty-Cart from URL
<?php
// empties the shopping cart
add_action( 'wp_loaded', 'custom_woocommerce_empty_cart_action', 20 );
function custom_woocommerce_empty_cart_action() {
if ( isset( $_GET['empty-cart'] ) && 'yes' === esc_html( $_GET['empty-cart'] ) ) {
WC()->cart->empty_cart();
}
}
@kidino
kidino / add-user-role.php
Created March 30, 2025 03:11
CLI tool to bulk add users through CSV file into WordPress with a role
<?php
// Ensure the script is run from CLI
if (php_sapi_name() !== 'cli') {
die("This script can only be run from the command line.\n");
}
// Check for required CLI arguments
if ($argc < 3) {
die("Usage: php import_users.php <csv_file> <role>\n");
}
@kidino
kidino / CheckoutController.php
Created November 21, 2024 08:18
SecurePay on Laravel
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use App\Models\Plan;
use App\Models\User;
use App\Models\Payment;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
@kidino
kidino / .htaccess
Last active September 26, 2024 04:48
Github Webhook Deploy Script
# taruk .htaccess untuk protect webhook.php agar hanya terima
# trafik daripada Github sahaja. Ini IP address Github yang
# akan hantar webhook.
# lepas tu sebab webhook.php akan pakai fungsi exec(), lagilah
# kita kena protect
<Files "webhook.php">
Order Deny,Allow
Deny from all
@kidino
kidino / user-payment.js
Created May 3, 2024 14:24
JavaScript for User Payment
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('payment_plan_id').addEventListener('change', (e) => {
let today = new Date();
let isoDate = today.toISOString().slice(0, 10); // Get ISO formatted date (YYYY-MM-DD)
let amount_input = document.getElementById('amount')
let new_expiry_input = document.getElementById('new_expiry')
let expiry_input = document.getElementById('expire_on')
@kidino
kidino / CountrySeeder.php
Created May 1, 2024 12:56
Country Seeder for Laravel
<?php
namespace Database\Seeders;
use App\Models\Country;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class CountrySeeder extends Seeder
{
@kidino
kidino / auto.barberos.test.conf
Created February 26, 2024 08:03
Laragon Apache Port Forwaring ProxyPass
define ROOT "C:/laragon/www/barberOS"
define SITE "barberOS.test"
<VirtualHost *:80>
DocumentRoot "${ROOT}"
ServerName ${SITE}
ServerAlias *.${SITE}
<Directory "${ROOT}">
AllowOverride All
Require all granted
@kidino
kidino / index.html
Created November 2, 2023 13:58
Mencuba Realtime Database dengan Pocketbase
<!--
Ini adalah kod daripada video Youtube yang saya buat untuk
mencuba realtime database menggunakan Pocketbase. Pocketbase
ada sistem backend yang memudahkan pembangunan API,
pengurusan pengguna, pengurusan data, dll. Pocketbase
dibangunkan dengan bahasa Go.
Untuk mencuba kod ini, tonton video YouTube bagaimana ia
digunakan bersama Pocketbase.
@kidino
kidino / customers.sql
Created October 19, 2023 06:33
Sample Customer Database (MariaDB)
-- MariaDB dump 10.19 Distrib 10.6.12-MariaDB, for Linux (x86_64)
--
-- Host: mysql.hostinger.ro Database: u574849695_17
-- ------------------------------------------------------
-- Server version 10.6.12-MariaDB-cll-lve
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

To retrieve a list of locations within a certain distance (e.g., 5 kilometers) from a given latitude-longitude location using MySQL's spatial features, you can use the Haversine formula, which calculates distances on the Earth's surface based on latitude and longitude. Here's how you can do it step by step:

  1. Create a Spatial Table:
    • You need to have a spatial-enabled table where you store the latitude and longitude coordinates for each location. You can create a table with a POINT column for this purpose. For example:
    CREATE TABLE locations (
        id INT AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(255),
        coordinates POINT
    );