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
from rest_framework import serializers | |
# | |
# Use in your Serializer for fields that you want to be required only when certain crieteria is met | |
# | |
class ConditionalRequiredMixin(serializers.BaseSerializer): | |
# List of fields that may be required | |
conditionally_required: List[str] = [] | |
# Override in your serializer to set required attribute |
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
add_filter( 'woocommerce_order_number', 'arglebargle_set_order_prefix' ); | |
function arglebargle_set_order_prefix( $order_id ) { | |
switch ( get_locale() ) { | |
case 'hr': | |
$prefix = 'HR-'; | |
break; | |
default: | |
$prefix = 'SI-'; | |
break; | |
} |
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
// Add this to your single.php or somewhere else where you see fit. :) | |
// | |
$post_id = get_the_ID(); | |
// Extract post tags | |
$tags = get_the_terms( $post_id, 'post_tag' ); | |
$tag_list = wp_list_pluck( $tags, 'term_id' ); | |
$tag_list = implode( ',', $tag_list ); | |
// Select post ID's from term_relationships table and order by those that match the most number of tags |
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
variants: { | |
margin: ['responsive', 'last-child', 'first-child', 'odd-child', 'even-child'], | |
}, | |
plugins: [ | |
function({ addVariant, e }) { | |
addVariant('first-child', ({ modifySelectors, separator }) => { | |
modifySelectors(({ className }) => { | |
return `.${e(`first-child${separator}${className}`)}:first-child` | |
}) | |
}) |
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
on("ready", function() { | |
log("Woo, I am here!"); | |
on('chat:message', function(msg) { | |
var ones = 0, | |
total = 0, | |
hits = 0, | |
res, | |
who, | |
re = new RegExp("^{{name=(.*?)}}"); | |
if (msg.type !== "api") { |
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
add_action( 'shutdown', 'do_shutdown', 999); | |
function do_shutdown() { | |
$f = fopen('/tmp/memory_usage.txt', 'a+'); | |
$usage = memory_get_peak_usage( true ); | |
fwrite( $f, $usage / 1024 / 1024 . " MB\n" ); | |
fclose( $f ); | |
} |