Skip to content

Instantly share code, notes, and snippets.


Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
staaldraad /
Last active Jan 6, 2022
AWK to get details from /proc/net/tcp and /proc/net/udp when netstat and lsof are not available
# Gawk version
# Remote
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}'
# Local
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}'
# No Gawk
# Local
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
mikejolley / gist:c4606aa52754b334f0f1bbe7e5b5ca6b
Created Jun 30, 2016
WooCommerce - remove payment method from emails
View gist:c4606aa52754b334f0f1bbe7e5b5ca6b
<?php // Do not include this if already open!
* Code goes in theme functions.php.
add_filter( 'woocommerce_get_order_item_totals', 'custom_woocommerce_get_order_item_totals' );
function custom_woocommerce_get_order_item_totals( $totals ) {
unset( $totals['payment_method'] );
return $totals;
mikejolley / functions.php
Created May 10, 2016
WooCommerce - Remove product data tabs and hook content in sequence instead
View functions.php
<?php // Do not include this if already open!
* Remove existing tabs from single product pages.
function remove_woocommerce_product_tabs( $tabs ) {
unset( $tabs['description'] );
unset( $tabs['reviews'] );
unset( $tabs['additional_information'] );
return $tabs;
mikejolley / functions.php
Created Mar 10, 2016
WooCommerce Disable guest checkout for certain products
View functions.php
// Code goes in theme functions.php or a custom plugin
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' );
function conditional_guest_checkout_based_on_product( $value ) {
$restrict_ids = array( 1, 2, 3 ); // Replace with product ids which cannot use guest checkout
if ( WC()->cart ) {
$cart = WC()->cart->get_cart();
mikejolley / gist:e73f9d061aaebd25ccdc
Created Feb 22, 2016
WooCommerce - Remove subtotal row.
View gist:e73f9d061aaebd25ccdc
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );
function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
mikejolley / gist:9f5adb8d194d7681e7b7
Last active Feb 5, 2021 — forked from corsonr/gist:6681929
WooCommerce - Create a product categories dropdown list in a shortcode
View gist:9f5adb8d194d7681e7b7
* WooCommerce Extra Feature
* --------------------------
* Register a shortcode that creates a product categories dropdown list
* Use: [product_categories_dropdown orderby="title" count="0" hierarchical="0"]
Tblue /
Last active Dec 30, 2021
MozLz4a compression/decompression utility
#!/usr/bin/env python
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to
# compress e. g. bookmark backups (*.jsonlz4).
# This file format is in fact just plain LZ4 data with a custom header (magic number [8 bytes] and
# uncompressed file size [4 bytes, little endian]).
# This Python 3 script requires the LZ4 bindings for Python, see:
denji /
Last active Jan 16, 2022
NGINX tuning for best performance

Moved to git repository:

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

maestrith / Imgur_Upload.ahk
Last active Dec 19, 2015
Upload an image to Imgur: Instructions Below:
View Imgur_Upload.ahk