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
/** | |
* Check if a given ip is in a network | |
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1 | |
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed | |
* @return boolean true if the ip is in this range / false if not. | |
*/ | |
function ip_in_range( $ip, $range ) { | |
if ( strpos( $range, '/' ) == false ) { | |
$range .= '/32'; | |
} |
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 | |
add_action( 'generate_rewrite_rules', 'debug_action_generate_rewrite_rules', 1, 1 ); | |
// debug http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1592 | |
// this should only be hit if the rewrite_rules option is empty. | |
// http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1616 | |
function debug_action_generate_rewrite_rules( $rules ) { | |
global $debug_action_rules; | |
error_log( __FUNCTION__ . ' : ' . __LINE__ ); | |
error_log( var_export( $_SERVER, true ) ); | |
error_log( "Rules Option: " . var_export( get_option( 'rewrite_rules' ), true ) ); |
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 python | |
""" | |
Produces load on all available CPU cores | |
""" | |
from multiprocessing import Pool | |
from multiprocessing import cpu_count | |
def f(x): | |
while True: |
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 | |
add_filter( | |
'ep_prepare_meta_data', | |
function ( $meta ) { | |
$meta_groups = [ | |
'group1' => [ | |
'_sku', | |
'_sale_price_dates_from', | |
'_sale_price_dates_to', | |
], |
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 | |
/** | |
* Helper script that can be run in cron to bug you when you forgot to run a harvest timer. | |
* install terminal-notifier via: | |
* sudo gem install terminal-notifier | |
* Make sure to adjust your credentials. | |
* Schedule via crontab -e to run weekdays 9-5 | |
* <star>/10 09-17 * * 1-5 php <path-to-script> | |
* replace <star> with * | |
*/ |
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 | |
add_action( 'http_api_debug', 'my_http_api_debug', 10, 5 ); | |
function my_http_api_debug( $response, $type, $class, $args, $url ) { | |
error_log( 'requested url: ' . var_export( $url, true ) ); | |
error_log( 'arguments: ' . var_export( $args, true ) ); | |
error_log( 'http response : ' . var_export( $response, true ) ); | |
} |
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
polybar config | |
[module/date] | |
type = custom/script | |
exec = ~/scripts/popup-calendar.sh | |
interval = 5 | |
click-left = ~/scripts/popup-calendar.sh --popup | |
format-background = ${colors.alt-background} | |
format-foreground = ${colors.alt-foreground} | |
label = %output:25% |
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 | |
# Get token from edit profile API & Mobile https://developer.teamwork.com/projects/apikey/key | |
# Get auth string by base64 encoding <token>:<randomstring> | |
# https://www.base64encode.org/ can be used to create such encoded string | |
token=<authstring> | |
authString="Authorization: Basic $token" | |
# Get user id from your profile url (/#/people/<userid>/tasks) | |
userId=<userid> |
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( | |
'ep_weighting_configuration_for_search', | |
function( $weighting_config ) { | |
global $wpdb; | |
$post_meta = get_transient( 'custom_ep_distinct_post_meta' ); | |
| |
if ( ! $post_meta ) { | |
$post_meta = $wpdb->get_col( | |
"SELECT DISTINCT meta_key | |
FROM {$wpdb->postmeta} pm |
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( 'ep_prepare_meta_data', function( $meta ) { | |
foreach( $meta as $key => $value ) { | |
if ( preg_match( '/.+_([0-9]+)_.+/', $key ) ) { | |
unset( $meta[$key] ); | |
} | |
} | |
return $meta; | |
} ); |
NewerOlder