Skip to content

Instantly share code, notes, and snippets.

View brycehamrick's full-sized avatar

Bryce Hamrick brycehamrick

View GitHub Profile
@brycehamrick
brycehamrick / keybase.md
Last active August 29, 2015 14:02
keybase.md

Keybase proof

I hereby claim:

  • I am brycehamrick on github.
  • I am bhamrick (https://keybase.io/bhamrick) on keybase.
  • I have a public key whose fingerprint is DDCF 527B 51DA 7A56 D3EE C023 3714 2CF3 37AA 9060

To claim this, I am signing this object:

@brycehamrick
brycehamrick / Archive\cA.scpt
Created December 10, 2014 20:11
Outlook Archive Script
tell application "Microsoft Outlook"
activate
set msgSet to current messages
if msgSet = {} then
error "No messages selected. Select at least one message."
error -128
end if
set theMsg to item 1 of msgSet
set theAccount to account of theMsg
set archiveFolder to folder "Archive" of theAccount
Verifying I am +bhamrick on my passcard. https://onename.com/bhamrick
@brycehamrick
brycehamrick / gist:77027271cfea0a18178d
Last active February 28, 2016 18:58
A Bash function to leverage the WP-CLI utility when using serverpilot.io to manage your WordPress server.
# First download the wp-cli.phar file from wp-cli.org and update the location below.
# Add the following function to your bash profile
wp() { sudo -u serverpilot -i -- /opt/sp/php7.0/bin/php /usr/local/bin/wp-cli.phar "$@" --path="$PWD" ;}
@brycehamrick
brycehamrick / gist:f4477989e4b95e0f607f3f1b93484409
Last active June 23, 2016 18:05
This script is what I use in an Alfred workflow to add tasks to Remember The Milk via email (sent through Mailgun). Change the Mailgun API key, add your domain to the Mailgun API URL, update the From address, change the To address to your RTM task address, and throw this into a Workflow as "Run Script" using /bin/bash.
curl -s --user 'api:key-xxxxxxxxxxxxxxxxxxxxxxxxxx' https://api.mailgun.net/v3/domain.com/messages -F from='Bryce Hamrick <bryce@domain.com>' -F to='username+asdf@rmilk.com' -F subject='{query}' -F text='--'
@brycehamrick
brycehamrick / woocommerce-top-sold-products.sql
Created September 19, 2017 20:10
SQL statement to grab all products and quantities sold between two dates.
SELECT oi.order_item_name, count(oi.order_item_id) as items_sold
FROM wp_woocommerce_order_items oi
LEFT JOIN wp_posts p ON p.ID = oi.order_id
WHERE p.post_status = 'wc-completed'
AND p.post_date BETWEEN "2017-06-01" AND "2017-09-18"
GROUP BY order_item_name
ORDER BY items_sold DESC;
@brycehamrick
brycehamrick / gist:e0b3255a8a15e6ce9ba3e8407f4a5497
Created February 2, 2018 06:26
Adds redirect_to support for the woocommerce my account login form
function filter_woocommerce_login_redirect( $redirect, $user ) {
$new_redirect = (isset($_GET['redirect_to'])) ? $_GET['redirect_to'] : $redirect;
return $new_redirect;
};
add_filter( 'woocommerce_login_redirect', 'filter_woocommerce_login_redirect', 10, 2 );
@brycehamrick
brycehamrick / woocommerce-disable-guest-for-virtual.php
Created February 19, 2018 06:26
Disable guest checkout if virtual products are in the cart.
<?php
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' );
function conditional_guest_checkout_based_on_product( $value ) {
if ( WC()->cart ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $item ) {
$product = $item['data'];
if(!empty($product) && $product->is_virtual()){
$value = "no";
@brycehamrick
brycehamrick / get-orders.sql
Last active July 24, 2018 02:42 — forked from lukecav/Command
Sales by SKU using a MySQL query if using WooCommerce
SELECT
sku, count(1)
FROM
wp_woocommerce_order_items oi, -- orders table
wp_posts p, -- woocommerce use posts to keep metadata on the order
wp_postmeta pm, -- we use this table to filter the completed orders
wp_postmeta pm1, -- we use this table again for getting the shipping country info
wp_woocommerce_order_itemmeta oim, -- use this table to get product ids from orders
(SELECT p.id as product_id, meta_value as sku FROM wp_posts p, wp_postmeta pm where
post_type='product' and post_status='publish'
Verifying my Blockstack ID is secured with the address 142jtxEBrxXdDFKVYCZa949RoggN5sf82z https://explorer.blockstack.org/address/142jtxEBrxXdDFKVYCZa949RoggN5sf82z