A HTML/CSS Class Naming Convention for Scalable/Modular CSS.
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
export function levenshteinDistance(a: string, b: string): number { | |
if (typeof a !== "string" || typeof b !== "string") { | |
throw new TypeError("Arguments must be of type `string`"); | |
} | |
if (arguments.length > 2) { | |
throw new RangeError("Too many arguments"); | |
} | |
if (a === b) { |
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
#!/bin/sh | |
print_usage() { | |
echo "usage: compress_video <input_file>" | |
echo "supported formats: mp4, webm, mkv, mov, avi, flv" | |
} | |
get_extension() { | |
f="${1##*/}" | |
case "$f" in |
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
/** | |
* Transforms a function that returns either a direct value or a thunk (a | |
* no-argument function that returns a value) into a function that only returns | |
* a direct value. It does this by repeatedly evaluating the function if it | |
* returns a thunk, until a direct value is obtained. | |
* | |
* @template T The type of the value to be returned by the trampoline function. | |
* @template A The type tuple representing the argument types accepted by the | |
* function f. | |
* @param f A function that takes arguments of type A and returns either a |
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
export async function fetchAll(urls: string[], concurrency = 5, retryPolicy = defaultRetryPolicy): Promise<Response[]> { | |
const controller = new AbortController(); | |
const semaphore = new Semaphore(concurrency); | |
const promises = urls.map(async url => { | |
await semaphore.acquire(); | |
try { | |
return await fetchWithRetry(url, retryPolicy, controller.signal); | |
} catch (error) { | |
controller.abort(); // abort all requests on fatal error | |
throw error; |
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
// Render fields at the bottom of variations - does not account for field group order or placement. | |
add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) { | |
global $abcdefgh_i; // Custom global variable to monitor index | |
$abcdefgh_i = $loop; | |
// Add filter to update field name | |
add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' ); | |
// Loop through all field groups | |
$acf_field_groups = acf_get_field_groups(); | |
foreach( $acf_field_groups as $acf_field_group ) { |
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
#!/usr/bin/env bash | |
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done | |
git fetch --all | |
git pull --all |
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 | |
/** | |
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it. | |
* For more information on the Register Helper Add-on please visit https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
**/ | |
function my_pmprorh_init() | |
{ | |
//don't break if Register Helper is not loaded |
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 | |
//define('SECONDS_IN_A_MINUTE', 60); | |
//define('SECONDS_IN_A_HOUR', 3600); | |
//define('SECONDS_IN_A_DAY', 86400); | |
//define('SECONDS_IN_A_WEEK', 604800); | |
//define('SECONDS_IN_A_MONTH', 2592000); | |
//define('SECONDS_IN_A_YEAR', 31536000); | |
/** |
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
!function() { | |
var doc = document, | |
htm = doc.documentElement, | |
lct = null, // last click target | |
nearest = function(elm, tag) { | |
while (elm && elm.nodeName != tag) { | |
elm = elm.parentNode; | |
} | |
return elm; | |
}; |
NewerOlder