Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
WillBrubaker / file.php
Last active April 9, 2024 18:44
WooCommerce Colorado Retail Delivery Fee
// not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
// BTC Donations to: bc1q0cwjuxxqqmwnxxc0m2xkkyf4kes9e0gejc9u0l
/**
* Add a .27 surcharge to orders shipping to Colorado
*/
add_action('woocommerce_cart_calculate_fees', 'handsome_bearded_guy_custom_surcharge');
function handsome_bearded_guy_custom_surcharge() {
global $woocommerce;
@michaellihs
michaellihs / twisted.md
Last active August 27, 2024 17:07
Write your own ssh Server with the Python Twisted library

SSH Server with the Python Twisted Library

Installing the library

Assuming you have Python installed on your system:

pip install twisted
pip install pyOpenSSL
pip install service_identity
@azadkuh
azadkuh / vim-cheatsheet.md
Last active February 17, 2025 17:33
vim / vimdiff cheatsheet - essential commands

Vim cheat sheet

Starting Vim

vim [file1] [file2] ...

@rickycheers
rickycheers / ucwords.js
Created January 15, 2013 19:45
ucwords in JavaScript - Equivalent to PHP's ucwords() Returns a string with the first letter in upper case of each word.
String.prototype.ucwords = function() {
str = this.toLowerCase();
return str.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,
function(s){
return s.toUpperCase();
});
};
@wesbos
wesbos / is_blog.php
Created September 2, 2011 19:32
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>