Skip to content

Instantly share code, notes, and snippets.

@ve3
ve3 / normalize-newline-large-txt-file.php
Created May 21, 2024 07:59
Normalize new line of large text file.
<?php
/**
* Normalize new line from anything (CR, CRLF) to be LF only.
* This will be replace new line from a file, line by line.
*/
// your file.
$textFile = '/path/to/my/file.txt';
@ve3
ve3 / wp-hooks-trace.php
Last active December 24, 2023 13:33
WordPress hooks (actions & filters) trace.
<?php
/**
* Plugin Name: WP hooks trace
* Description: Enable trace > browse or work > disable trace. And everything will be written into this plugin folder /hooks-trace.txt file.
* License: MIT
*/
// You can use this plugin for any purpose without attribution required.
add_filter('plugin_row_meta', 'rdht_pluginRowMeta', 10, 4);
@ve3
ve3 / profit-calculator.html
Last active November 18, 2023 07:23
profit calculator. demo ( https://codepen.io/ve3/pen/GRzyzLJ )
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>คำณวนกำไร</title>
<style type="text/css">
button,
input[type="button"],
input[type="submit"],
@ve3
ve3 / index.html
Last active August 9, 2023 15:22
Bootstrap 5 one sidebar layout best fit for help & support page. (preview https://codepen.io/ve3/pen/MWzdEvj)
<!doctype html>
<html lang="th">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ความช่วยเหลือ &amp; สนับสนุน</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<link rel="stylesheet" href="../assets/css/support-style.css">
</head>
@ve3
ve3 / Encryption.js
Created February 6, 2023 14:37
Cross languages encrypt/decrypt with AES-256-GCM
'use strict';
/**
* Encryption class for encrypt/decrypt data.
*/
export default class Encryption {
@ve3
ve3 / YouTubeURL.js
Created December 14, 2022 10:55
JavaScript YouTube URL class
/**
* YouTube URL.
*
* @author Vee W.
*/
class YouTubeURL {
@ve3
ve3 / fa6-icons-renamed.php
Created March 12, 2022 07:04
Font Awesome 6 icons renamed
<?php
// Icons that was renamed in Font Awesome 6. 👎👎👎👎👎
// https://fontawesome.com/docs/web/setup/upgrade/whats-changed#icons-renamed-in-version-6
// The array format is [old name] => new name.
// The first array set is without `fa-` prefix.
$renamed = array (
'ad' => 'rectangle-ad',
'adjust' => 'circle-half-stroke',
'air-freshener' => 'spray-can-sparkles',
@ve3
ve3 / str_contains.php
Last active January 3, 2022 04:50
PHP `str_contains()` polyfill
<?php
if (!function_exists('str_contains')) {
/**
* Determine if a string contains a given substring
*
* @link https://www.php.net/manual/en/function.str-contains.php PHP `str_contains` original document.
* @param string $haystack The string to search in.
* @param string $needle The substring to search for in the `haystack`.
* @return bool Returns `true` if `needle` is in `haystack`, `false` otherwise.
@ve3
ve3 / Antibot.js
Last active December 22, 2021 08:39
Spambot prevention
/**
* Antibot JS class.
*/
class Antibot {
/**
* Setup honeypot form group.
@ve3
ve3 / strftime-to-intldateformatter-converter.php
Last active June 19, 2023 12:33
Convert strftime format to IntlDateFormatter pattern.
<?php
/**
* PHP `strftime()` format to `IntlDateFormatter()` pattern converter.
*
* PHP `strftime()` is deprecated since v 8.1. They recommended to use `IntlDateFormatter()` instead.
* However `IntlDateFormatter()` pattern does not fully supported all format that `strftime()` does.
*
* Run this file to get the result of most close pattern to `strftime()` based on Thai locale.
*
* @license MIT