This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://stackoverflow.com/a/48896992/933782 | |
function jwt_request($token, $post) { | |
header('Content-Type: application/json'); // Specify the type of data | |
$ch = curl_init('https://APPURL.com/api/json.php'); // Initialise cURL | |
$post = json_encode($post); // Encode the data array into a JSON string | |
$authorization = "Authorization: Bearer ".$token; // Prepare the authorisation token | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization )); // Inject the token into the header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Reference/source: http://stackoverflow.com/a/1464155/933782 | |
* | |
* I want a short alphanumeric hash that’s unique and who’s sequence is difficult to deduce. | |
* I could run it out to md5 and trim the first n chars but that’s not going to be very unique. | |
* Storing a truncated checksum in a unique field means that the frequency of collisions will increase | |
* geometrically as the number of unique keys for a base 62 encoded integer approaches 62^n. | |
* I’d rather do it right than code myself a timebomb. So I came up with this. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Flexbox Dead Center</title> | |
<style> | |
.deadcenter { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
flex-direction: column; | |
height: 100%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |