Skip to content

Instantly share code, notes, and snippets.

@zgordon
zgordon / gravityforms-learndash-groups.php
Last active March 10, 2020 17:17
This function hooks in when Gravity Forms Registers a New User and then Adds them to a LearnDash Group using ld_update_group_access
<?php
add_action( 'gform_activate_user', 'apply_learndash_group', 10, 3 );
function apply_learndash_group( $user_id, $user_data ) {
// Change to be group ID for your group
$group_id = XXXX;
@anfederico
anfederico / dust.py
Created January 22, 2018 01:57
Get rid of dust on your Binance account
# pip install python-binance
from binance.client import Client
client = Client(api_key, api_secret)
DUST = 0.001 # BTC
account = client.get_account()
prices = client.get_all_tickers()
@zgordon
zgordon / learndash-groups-woocommerce.php
Last active August 21, 2019 00:06
Assign users to a LearnDash Group when they purchase a specific WooCommerce product
<?php
// Add user to LearnDash Group if purchases specific WooCommerce product
function jsforwp_add_user_to_group( $order_id ) {
// Add group ID from LearnDash here
$ld_group_id = XXXX;
// Add product ID from WooCommerce here
$wc_product_id = XXXX;
$order = new WC_Order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
@mortensteenrasmussen
mortensteenrasmussen / cleanupManifestsWithoutTags.sh
Last active September 9, 2024 08:12
Clean up untagged manifests in private docker registry
#!/bin/bash
REGISTRY_DIR=YOUR_REGISTRY_DIR/data/docker/registry/v2/repositories
REGISTRY_URL=http://10.10.10.10:5000
#add --insecure to the curl command on line 17 if you use https with self-signed certificates
cd ${REGISTRY_DIR}
count=0
manifests_without_tags=$(comm -23 <(find . -type f -name "link" | grep "_manifests/revisions/sha256" | grep -v "\/signatures\/sha256\/" | awk -F/ '{print $(NF-1)}' | sort) <(for f in $(find . -type f -name "link" | grep "_manifests/tags/.*/current/link"); do cat ${f} | sed 's/^sha256://g'; echo; done | sort))
# -*- coding: utf-8 -*-
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.
Example:
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including
@kevinelliott
kevinelliott / osx-10.11-setup.md
Last active September 5, 2024 01:54
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@frozonfreak
frozonfreak / function.php
Last active November 20, 2018 15:54
WooCommerce apply coupon for regular price instead of sale price
add_filter('woocommerce_coupon_get_discount_amount', 'woocommerce_coupon_get_discount_amount', 10, 5 );
function woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, $cart_item, $single, $coupon ) {
if ($coupon->type == 'percent_product' || $coupon->type == 'percent') {
global $woocommerce;
$cart_total = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
$variable_product1= new WC_Product_Variation( $cart_item["variation_id"] );
anonymous
anonymous / Pull-Menu---Menu-Interaction-Concept.markdown
Created December 26, 2014 16:40
Pull Menu - Menu Interaction Concept
@nickburne
nickburne / gist:192609fedc540654fd9b
Last active September 16, 2015 23:25
Replace add to cart button with button to product page - WooCommerce
/*PUT THIS IN YOUR CHILD THEME FUNCTIONS FILE*/
/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');
@wkjagt
wkjagt / audio-book-reader.md
Last active April 12, 2024 14:18
How I built an audio book reader for my nearly blind grandfather

#How I built an audio book reader for my nearly blind grandfather

Tweet this - Follow me

Last year, when visiting my family back home in Holland, I also stopped by my grand-parents. My grand-father, now 93 years old, had always been a very active man. However, during the presceding couple of months, he'd gone almost completely blind and now spent his days sitting in a chair. Trying to think of something for him to do, I suggested he try out audio books. After finally convincing him -- he said audio books were for sad old people -- that listening to a well performed recording is actually a wonderful experience, I realized the problem of this idea.

####The problem with audio devices and the newly blind. After my first impulse to jump up and go buy him an