Skip to content

Instantly share code, notes, and snippets.

View bradp's full-sized avatar
🏖️
beach vibes

Brad Parbs bradp

🏖️
beach vibes
View GitHub Profile
@bradp
bradp / brad_bot.rb
Created March 29, 2013 22:17
brad_bot_make_circles
class BradBot < RTanque::Bot::Brain
NAME = 'brad_bot'
include RTanque::Bot::BrainHelper
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 5.0
def tick!
## main logic goes here
# use self.sensors to detect things
# use self.command to control tank
@bradp
bradp / remove-yoast-images.php
Created June 3, 2013 18:47
Removes Yoast SEO advertisment images in the WordPress dashboard
function wolf_admin_styles() {
echo '<style type="text/css">
a[href*="yoast.com"] img{ display: none; }
</style>';
}
add_action('admin_head', 'wolf_admin_styles');
@bradp
bradp / untitled.html
Last active December 19, 2015 04:29
Inline-block Ul height example for J
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<style>
ul{
display: inline-block;
height: inherit;
}
@bradp
bradp / something.php
Created August 6, 2013 19:49
get_out_of_here_yoast_what_are_you_doing
<?php
function bo_get_out_of_here_yoast_what_are_you_doing() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'bo_get_out_of_here_yoast_what_are_you_doing');
@bradp
bradp / ugh.php
Created January 14, 2014 05:04
dont_do_this
<?php
//dis like the best code ever
function register()
{
if (!empty($_POST)) {
$msg = '';
if ($_POST['user_name']) {
if ($_POST['user_password_new']) {
@bradp
bradp / global-post-exclusion.php
Last active August 17, 2016 20:35
Filters queries to exclude posts that already exist on a page. Call `wds_add_to_global_exclusions( $post_id )` to add to the list.
<?php
/**
* Plugin Name: Global Post Exclusion
* Description: Uses global variables to store post IDs and remove them from other queries.
*/
/**
* Filters queries on pre_get_posts to exclude posts that are excluded.
*
* @param object $query current WP Query
<?php
// Filter is in wpforms/src/Forms/Token.php - get_valid_tokens();
// Create our array of times to check before today. A user with a longer
// cache time can extend this. A user with a shorter cache time can remove times.
$valid_token_times_before = apply_filters(
'wpforms_form_token_check_before_today',
[
( 2 * DAY_IN_SECONDS ), // Two days ago.
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst
autoload -U add-zsh-hook
PROMPT_SUCCESS_COLOR=$FG[117]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]
@bradp
bradp / gist:4999343
Last active September 5, 2022 20:36
WordPress function to convert address to Lat/Long
<?php
function brrad_geocode($street_address,$city,$state){
$street_address = str_replace(" ", "+", $street_address); //google doesn't like spaces in urls, but who does?
$city = str_replace(" ", "+", $city);
$state = str_replace(" ", "+", $state);
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$street_address,+$city,+$state&sensor=false";
$google_api_response = wp_remote_get( $url );
@bradp
bradp / gist:8b379e71daa4b6a61d14
Last active August 14, 2023 08:40
Useful SQL Queries
#Get the size of each table, ordered by largest to smallest
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "YOU+TABLE+NAME+HERE"
ORDER BY (data_length + index_length) DESC;
#Get the size of the entire DB
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"