Skip to content

Instantly share code, notes, and snippets.

@ve3
ve3 / data-from-versioncontrol-steamdb.php
Last active April 26, 2019 04:45
Kingdom Rush Origins format save data to readable achievements.
<?php
if (!is_file('filtered-savefile.php')) {
die('Unable to get filtered data, please run save-file.php first.');
}
require 'filtered-savefile.php';
// https://steamdb.info/app/816340/history/
@ve3
ve3 / functions.php
Last active July 14, 2019 08:10
Check password hash length for each algo.
<?php
function printDebug($var)
{
echo '<pre>' . print_r($var, true) . '</pre>' . PHP_EOL;
}
/**
@ve3
ve3 / timezone-selectbox.php
Last active November 17, 2019 07:24
Generate timezones list array
<?php
function getTimezones(): array
{
$timezones = \DateTimeZone::listIdentifiers();
$options = [];
$lastRegion = '';
if (is_array($timezones)) {
foreach ($timezones as $key => $timezone) {
$DateTimeZone = new \DateTimeZone($timezone);
@ve3
ve3 / thai-characters.php
Last active August 13, 2020 14:59
PHP: list Thai characters in array. แสดงอักขระภาษาไทยเป็น array.
<?php
echo '<meta charset="utf-8">' . PHP_EOL;
/*for ($i = 0; $i <= 255; $i++) {
$string = chr($i);
echo $i . ' =&gt; ';
echo iconv('tis-620', 'utf-8//IGNORE', $string);
@ve3
ve3 / demo1-max-concurrent-wait-all.html
Last active June 17, 2021 16:41
Ajax (XHR) with max concurrent connection.
<!--demo1-max-concurrent-wait-all.html-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>XHR multi concurrent connection</title>
<style>
#debug {
border: 3px dashed #ccc;
margin: 10px 0;
@ve3
ve3 / Antibot.js
Last active December 22, 2021 08:39
Spambot prevention
/**
* Antibot JS class.
*/
class Antibot {
/**
* Setup honeypot form group.
@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 / YouTubeURL.js
Created December 14, 2022 10:55
JavaScript YouTube URL class
/**
* YouTube URL.
*
* @author Vee W.
*/
class YouTubeURL {
@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/bootstrap@5.3.1/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
Last active August 10, 2023 10:51
Encrypt and decrypt between programming languages (PHP & JavaScript). (Newer version here https://gist.github.com/ve3/b16b2dfdceb0e4e24ecd9b9078042197 )
/**
* Encryption class for encrypt/decrypt that works between programming languages.
*
* @author Vee Winch.
* @link https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs Reference.
* @link https://github.com/brix/crypto-js/releases crypto-js.js can be download from here.
*/
class Encryption {