Skip to content

Instantly share code, notes, and snippets.

View kidino's full-sized avatar

Iszuddin Ismail kidino

View GitHub Profile
@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
    );
@kidino
kidino / foo_tickets_export.sql
Created September 6, 2022 02:32
Exporting FooEvent Tickets
## THIS IS FOR EXPORTING TICKETS FROM YOUR FOO EVENT WOOCOMMERCE PLUGIN.
## I CREATED THIS BECAUSE I HAVE A DIFFERENT SYSTEM FOR USERS TO LOGIN TO AND
## I WOULD LIKE THE USERS TO BE ABLE TO USE THE SAME TICKET. IN THE NEW SYSTEM
## I REGENERATE THE QR BASED ON TICKET_ID.
SELECT wp00_posts.ID, wp00_posts.post_title, wp00_posts.post_type,
max(case when (meta_key='WooCommerceEventsTicketID') then meta_value else NULL end) as 'Ticket_ID',
max(case when (meta_key='WooCommerceEventsAttendeeName') then meta_value else NULL end) as 'First_Name',
max(case when (meta_key='WooCommerceEventsAttendeeLastName') then meta_value else NULL end) as 'Last_Name',
max(case when (meta_key='WooCommerceEventsAttendeeEmail') then meta_value else NULL end) as 'Email',
@kidino
kidino / query_user.sql
Created November 4, 2021 03:48
Query WP Users and User Meta (based on user roles) into Columns and Filtering
/*
in this example, we are querying users with specific roles and their billing phone numbers
see how we are creating dynamic columns with max and case
also how where are using HAVING to filter group data
*/
SELECT wp_users.display_name, wp_users.user_email,
max(case when (meta_key='billing_phone') then meta_value else NULL end) as 'billing_phone',
@kidino
kidino / toggle-button.json
Created April 28, 2020 04:17
Pricing Table with Toggle Button for Elementor Pro
{"version":"0.4","title":"toggle-pricing-table","type":"section","content":[{"id":"7e71bb5a","settings":{"margin":{"unit":"px","top":"100","right":0,"bottom":"100","left":0,"isLinked":true}},"elements":[{"id":"1987f110","settings":{"_column_size":100,"_inline_size":null},"elements":[{"id":"2c2912c1","settings":{"content_width":{"unit":"px","size":195,"sizes":[]},"height_inner":"min-height","custom_height_inner":{"unit":"px","size":55,"sizes":[]}},"elements":[{"id":"28eca408","settings":{"_column_size":100,"_inline_size":null,"content_position":"center","align":"space-around","background_background":"classic","background_color":"#E7E7E7","border_radius":{"unit":"px","top":"10","right":"10","bottom":"10","left":"10","isLinked":true},"_element_id":"toggle-01","custom_css":"selector {\n cursor: pointer;\n}"},"elements":[{"id":"16108133","settings":{"button_type":"info","text":"-","size":"xs","button_text_color":"#ACAFEA","background_color":"#ACAFEA","border_radius":{"unit":"px","top":"5","right":"5","bottom":"
@kidino
kidino / toggle-button.css
Last active October 5, 2022 12:22
Creating a Toggle Button with Elementor Pro - The CSS & Javascript Code
/*
This is the CSS code for creating your own Toggle Button Widget using
Elementor Pro.
You still need the Javascript code for this to work.
The Youtube tutorial is here. Make sure you watch this to understand
how this works.
https://youtu.be/ZhBGPIU1bq0