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
//returns keys and values of $arr if key exist in $keys | |
function filter_array(array $arr, array $keys){ | |
$ret = array(); | |
foreach ( $keys as $k ){ | |
if (array_key_exists($k,$arr)){ | |
$ret[$k] = $arr[$k]; | |
} | |
} |
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('upw_wp_query_args', 'upw_only_posts_with_thumbnails',10 , 2); | |
function upw_only_posts_with_thumbnails($args, $instance) { | |
if ( $instance['show_thumbnail'] ) { | |
$args['meta_query'] = array( | |
array( | |
'key' => '_thumbnail_id', | |
'compare' => 'EXISTS' | |
) | |
); |
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/bash | |
# This script is based on code from https://github.com/angristan/wireguard-install and might not work if you use another script. Use it on your own responsibility. | |
# Usage: `./add-users.sh "marty;emmet;biff"` | |
# Check if WireGuard is already installed and load params | |
if [[ -e /etc/wireguard/params ]]; then | |
source /etc/wireguard/params | |
else | |
echo "wireguard is not installed, please install using this script: https://github.com/angristan/wireguard-install" |
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
dbsh() { | |
docker ps --format '{{.Names}}' | nl -s ") " | |
echo "Pick container" | |
read CONTAINER | |
CONTAINER_NAME=$(docker ps --format '{{.Names}}' | sed -n "${CONTAINER}p") | |
docker exec -ti $CONTAINER_NAME /bin/bash | |
} |
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
/** | |
Running 'SELECT create_monthly_partitions_for_partitioned_table( 'party_test', '2021-11-15', '2022-01-15' );' | |
Will result in executing the following statements: | |
`CREATE TABLE party_test_y2021_m11 PARTITION OF party_test FOR VALUES FROM ('2021-11-01 00:00:00+00') TO ('2021-12-01 00:00:00+00');` | |
`CREATE TABLE party_test_y2021_m12 PARTITION OF party_test FOR VALUES FROM ('2021-12-01 00:00:00+00') TO ('2022-01-01 00:00:00+00');` | |
`CREATE TABLE party_test_y2022_m01 PARTITION OF party_test FOR VALUES FROM ('2022-01-01 00:00:00+00') TO ('2022-02-01 00:00:00+00');` | |
*/ | |
CREATE OR REPLACE FUNCTION create_monthly_partitions_for_partitioned_table(base_table TEXT, start_month DATE, end_month DATE) RETURNS VOID AS | |
$$ |
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
/** | |
* ---------------------------------------------- | |
* Make Scenarios Consumption Data Extractor | |
* ---------------------------------------------- | |
* This script is designed to efficiently extract and process | |
* consumption data for various scenarios from Make's API. | |
* It enables easy integration of this data into spreadsheet applications | |
* by formatting the data for straightforward copy-pasting. | |
* | |
* |
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
/** | |
* A custom function that gets the driving distance between two addresses. | |
* | |
* @param {String} origin The starting address. | |
* @param {String} destination The ending address. | |
* @return {Number} The distance in meters. | |
*/ | |
function drivingDistance(origin, destination) { | |
const directions = getDirections(origin, destination); | |
return directions.routes?.[0]?.legs?.[0]?.distance?.value || 'Error'; |