Skip to content

Instantly share code, notes, and snippets.

@ethanpil
ethanpil / wc_make_processing_orders_editable.php
Created March 21, 2023 01:13
Make WooCommerce order status Processing editable
<?php
//https://nicolamustone.blog/2015/05/14/how-to-edit-processing-orders/
add_filter( 'wc_order_is_editable', 'wc_make_processing_orders_editable', 10, 2 );
function wc_make_processing_orders_editable( $is_editable, $order ) {
if ( $order->get_status() == 'processing' ) {
$is_editable = true;
}
return $is_editable;
@ethanpil
ethanpil / mark.sh
Created March 12, 2023 18:10
Shell Bookmark Directories
# https://news.ycombinator.com/item?id=35122780#35123388
# http://karolis.koncevicius.lt/posts/fast_navigation_in_the_command_line/
<<USAGE
mark @name # add bookmark called @name for the current directory
cd @name # jump to the bookmarked location
cd @<tab> # list all available bookmarks
USAGE
export CDPATH=.:~/.marks/
function mark {
@ethanpil
ethanpil / wordpress-custom-admin-menu.php
Created December 26, 2022 20:50
Re-Order and Hide Wordpress Admin Menu Items
<?php
/* How to Rearrange/Hide WordPress Admin Menu Links
Source: https://www.digital.ink/blog/wordpress-rearrange-admin-menu/
1) Find the URL slug of relevant menu items (everything past the /wp-admin/)
2) Re-order as in the first function.
3) Add separators as necessary.
NOTE: If you don’t add an item to your custom menu order, and don’t remove it completely,
it will fall in line below your custom order. So if you only want to re-order the first few
$gnuplotcommands = '
set terminal png size 640x480
set grid
set autoscale
unset log
unset label
set xtics 0,1,23
set ytic auto
set title "Sample Chart Data"
set xlabel "Date"
#install wkhmltopdf on alpine linux 3.15
apk add --update --no-cache --wait 10 libstdc++ libx11 libxrender libxext libssl1.1 ca-certificates fontconfig freetype ttf-dejavu ttf-droid ttf-freefont ttf-liberation && \
apk add --update --no-cache --virtual .build-deps msttcorefonts-installer
update-ms-fonts && fc-cache -f
rm -rf /tmp/* && apk del .build-deps
cd /usr/bin
curl -LJO https://github.com/khalilgharbaoui/wkhtmltopdf-binary-edge-alpine/raw/master/libexec/wkhtmltopdf-alpine-linux-amd64
mv wkhtmltopdf-alpine-linux-amd64 wkhtmltopdf
#https://codingwithmanny.medium.com/configure-self-signed-ssl-for-nginx-docker-from-a-scratch-7c2bcd5478c6
apk add nginx
mkdir /etc/ssl/private
openssl req -x509 -nodes -days 365 -subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" -addext "subjectAltName=DNS:mydomain.com" -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt;
mkdir /srv/www
chown -R nginx:nginx /srv/www
#Configuring nginx
@ethanpil
ethanpil / alpine-php7-mssql-pdo.sh
Last active November 4, 2022 03:54
alpine-php7-mssql-pdo
apk update
apk add --no-cache curl php7 php7-pdo php7-fpm unixodbc ca-certificates && update-ca-certificates pecl
cd /tmp
curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.2.2-1_amd64.apk
curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.5.2.1-1_amd64.apk
apk add --allow-untrusted msodbcsql17_17.5.2.2-1_amd64.apk
apk add --allow-untrusted mssql-tools_17.5.2.1-1_amd64.apk
url -L https://github.com/microsoft/msphpsql/releases/download/v5.10.1/Alpine315-7.4.tar | tar xv
cp /tmp/Alpine315-7.4/php_pdo_sqlsrv_74_nts.so /usr/lib/php7/modules/php_pdo_sqlsrv.so
@ethanpil
ethanpil / alpine-dropbear-ssh.sh
Last active November 4, 2022 18:41
Install Drop Bear SSH Deamon on Alpine Linux
#Install Dropbear
apk add dropbear
#Start the service
rc-service dropbear start
#Add it to the default runlevel
rc-update add dropbear
#Settings in /etc/conf.d/dropbear
#Setup Squeezebox / Logitech Music ona fresh alpine install
apk add --no-cache curl
curl -Ls http://www.sodface.com/repo/sodface-pub-key.tar.gz | tar -C /etc/apk/keys/ -xvz sod@sodface.com-5e51d361.rsa.pub
echo http://www.sodface.com/repo >> /etc/apk/repositories
apk add --no-cache espeak faad2 flac ffmpeg lame lms perl-crypt-cbc sox wavpack
apk del curl
mkdir /home/lms
mkdir /home/lms/cache
@ethanpil
ethanpil / pac_aliases
Created June 24, 2022 20:18 — forked from rroblak/pac_aliases
Package manager-independent bash aliases
# paci - install one or more packages
# pacu - upgrade all packages to their newest version
# pacr - uninstall one or more packages
# pacs - search for a package using one or more keywords
# pacinfo - show information about a package
# pacinstalled - show if a package is installed
# paca - list all installed packages
# paclo - list all packages which are orphaned
# pacdnc - delete all not currently installed package files
# pacfiles - list all files installed by a given package