Skip to content

Instantly share code, notes, and snippets.

View aliboy08's full-sized avatar

Alistair Ponce aliboy08

  • Philippines
View GitHub Profile
@aliboy08
aliboy08 / xdebug-settings.txt
Created August 30, 2024 03:47
xdebug settings
[xdebug]
{{#if os.windows}}
zend_extension = php_xdebug.dll
{{else}}
zend_extension = {{extensionsDir}}/xdebug.so
{{/if}}
{{#if xdebugEnabled}}
{{!-- xdebug.mode=debug,develop --}}
xdebug.mode=profile
@aliboy08
aliboy08 / audit.bat
Created August 30, 2024 03:24
measure load time
@echo off
setlocal enabledelayedexpansion
set url=https://next-level-racing-new.local/sample-home/
set runs=10
for /L %%i in (1,1,%runs%) do (
curl -o NUL -s -w "%%{time_total}\n" -H "Pragma: no-cache" "!url!"
)
@aliboy08
aliboy08 / batch_items.js
Created August 13, 2024 04:24
Batch items
export function batch_items(items, items_per_batch){
let batched_items = [];
let group_items = [];
let group_index = 0;
for( let i = 0; i < items.length; i++ ) {
group_index++;
group_items.push(items[i]);
@aliboy08
aliboy08 / publish.bat
Last active July 30, 2024 11:11
Plugin zip powershell script + upload to remote
@echo off
setlocal
set "plugin_name=plugin-boilerplate"
set "zip_file=%plugin_name%.zip"
set "source_path=%CD%"
set "exclude=node_modules;.git;_temp;zip.ps1;publish.bat;.gitignore;jsconfig.json;package.json;package-lock.json;wp-manifest.cjs;vite.config.js;%zip_file%"
echo Creating zip file...
@aliboy08
aliboy08 / before_after_slider.js
Created July 25, 2024 03:04
Before & After Slider
export default class Before_After_Slider {
constructor(el){
this.el = el;
this.init();
}
init(){
this.before = this.el.querySelector('.before_image');
@aliboy08
aliboy08 / upload_dist.bat
Last active July 2, 2024 08:32
WPEngine dist folder upload script
@echo off
setlocal
set install_name=bigdaddylocal
set theme_folder=fivebyfive
REM Set variables
set remote_base_dir=/sites/%install_name%/wp-content/themes/%theme_folder%/
set ssh_host=%install_name%@%install_name%.ssh.wpengine.net
@aliboy08
aliboy08 / wp-ajax-fetch-boilerplate.php
Last active May 1, 2024 12:11
wp ajax boilerplate with fetch
<?php
add_action('wp_ajax_ACTION_HERE', function(){
$response = [
'post' => $_POST,
];
wp_send_json($response);
});
?>
<script>
@aliboy08
aliboy08 / script_ready_check.js
Created March 28, 2024 04:12
Script ready checker
function script_ready_check(script, cb, interval, limit){
var time = 0;
var check = setInterval(function(){
if( typeof script !== 'undefined' ) {
clearInterval(check);
cb();
}
time += interval;
if( time >= limit ) {
clearInterval(check);
@aliboy08
aliboy08 / group-items.js
Created March 28, 2024 02:54
group array of items into multiple sub arrays
function group_items(items, items_per_group){
var groups = [
[],
];
var current_group = 0;
var group_items_count = 0;
for( var i = 0; i < items.length; i++ ) {
@aliboy08
aliboy08 / wp-vite.php
Last active March 15, 2024 13:36
WP + Vite
<?php
namespace FF\Vite;
function get_manifest(){
$manifest_file = __DIR__ . '/dist/.vite/manifest.json';
$manifest = wp_json_file_decode( $manifest_file );
return $manifest;
}
function get_mode(){