Skip to content

Instantly share code, notes, and snippets.

View connorhu's full-sized avatar
🖥️

Connor connorhu

🖥️
View GitHub Profile
@connorhu
connorhu / gen.sh
Last active March 2, 2024 21:50
generate rector rule to rename google api client alias
#!/bin/sh
echo "<?php" > rector_rule.php
echo "return [" >> rector_rule.php
for file in $(grep ^class_alias vendor/google/ -R | cut -d: -f1);
do
echo " '$(cat $file | grep ^class_alias | cut -d\' -f2)' => '$(cat $file | grep ^namespace | cut -d" " -f2 | cut -d\; -f1)\\$(cat $file | grep ^class\ | cut -d" " -f2)',";
done >> rector_rule.php
@connorhu
connorhu / update.sh
Last active January 16, 2023 12:36
phpmyadmin update script
#!/bin/sh
CURRENT_VERSION=$(ls -la | grep \ web | awk '{ print $11 }' | sed -e 's/phpMyAdmin-\(.*\)-all-languages/\1/') # '
VERSION_CONTENT=$(curl -s https://www.phpmyadmin.net/home_page/version.json | php -r 'echo json_decode(file_get_contents("php://stdin"), true)["version"];')
LATEST_VERSION=$(echo "$VERSION_CONTENT" | head -n1)
LATEST_VERSION_DL_URL="https://files.phpmyadmin.net/phpMyAdmin/${LATEST_VERSION}/phpMyAdmin-${LATEST_VERSION}-all-languages.zip"
PHP_VERSION="php8.2"
if [ ! -f config.inc.php ]
@connorhu
connorhu / phpbrew ext installs
Last active January 20, 2023 14:56
phpbrew ext
# php w mysql
# default:
# bcmath, bz2, calendar, cli, ctype, dom, fileinfo, filter, ipc,
# json, mbregex, mbstring, mhash, pcntl, pcre, pdo, pear, phar, posix,
# readline, sockets, tokenizer, xml, curl, openssl, zip
phpbrew install php-{version} +default +dbs +intl +soap
phpbrew ext install gd
phpbrew ext install iconv -- --with-iconv=/usr/local/opt/libiconv
SET @prefix = 'wp_';
SET @date_from = '2020-01-01';
SET @date_to = '2020-12-31';
SET @query = CONCAT('SELECT sum(woim.meta_value) number_of_item_sold, woi.order_item_name
FROM ', @prefix, 'woocommerce_order_itemmeta as woim
LEFT JOIN ', @prefix, 'woocommerce_order_items as woi ON woi.order_item_id = woim.order_item_id
LEFT JOIN ', @prefix, 'posts as p ON woi.order_id = p.ID
WHERE woim.meta_key = \'_qty\'
AND p.post_status = \'wc-completed\'
@connorhu
connorhu / build
Last active March 9, 2021 15:58
symfony build and deploy
#!/bin/bash
env=$1
if [ "$env" == "" ]
then
echo "env missing"
exit 1
fi