Skip to content

Instantly share code, notes, and snippets.

View greathmaster's full-sized avatar
🧐

Hersha Venkatesh greathmaster

🧐
  • San Francisco, Bay Area
View GitHub Profile
@greathmaster
greathmaster / debounce-abort-fetch.js
Created March 24, 2021 22:36 — forked from alexnoz/debounce-abort-fetch.js
Abort fetching data in a function when debouncing it
function debounceFetch (fn, delay, onCancel = () => {}) {
let timer = 0, isFetching = false
return function (...args) {
clearTimeout(timer)
if (isFetching) {
onCancel()
isFetching = false
}
@greathmaster
greathmaster / pmpro_after_checkout_send_gift_certificate_email.php
Last active November 20, 2020 16:26 — forked from strangerstudios/pmpro_after_checkout_send_gift_certificate_email.php
After PMPro checkout, if the purchase is a gift level send an email to the gift recipient. (See additional functionality in comments.)
/*
Send Gift Certificate email at checkout.
Requirements:
1. Paid Memberships Pro
2. The PMPro Gift Levels Addon
3. Register Helper Add On with a "gift_certificate_email" field added via custom code.
***MODIFIED***
Adds the email shortcode !!code_url!! so we can potentially use it in a custom email template with PMPro Email Templates plugin.
@greathmaster
greathmaster / discounts.php
Last active October 26, 2020 18:58 — forked from eighty20results/discounts.php
Add discount code column to order list
function my_pmpro_add_cols_header($order_ids) {
ob_start(); ?>
<th>Discount Code</th><?php
return ob_get_clean();
}
add_filter('pmpro_orders_extra_cols_header', 'my_pmpro_add_cols_header');
function my_pmpro_add_cols_body($order) {
@greathmaster
greathmaster / .block
Created March 24, 2020 19:14 — forked from mbostock/.block
Ocean
license: gpl-3.0
@greathmaster
greathmaster / System Design.md
Created March 24, 2020 19:11 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@greathmaster
greathmaster / rails_g.rb
Created January 27, 2020 22:49 — forked from awkale/rails_g.rb
rails generators #rails #cheatsheet
# Controller Plural
rails g controller Users index show
# Helper Plural
rails g helper Users
# Mailer Singular
rails g mailer UserMailer
# Migration Plural
@greathmaster
greathmaster / Trie.js
Created July 20, 2019 07:23 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;
@greathmaster
greathmaster / upload-file-example-pmpro.php
Created February 5, 2019 01:05 — forked from andrewlimaza/upload-file-example-pmpro.php
PMPro Register Helper Upload File Example
<?php
//Copy lines 5 onwards into your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
@greathmaster
greathmaster / my_change_pmpro_sessions_start_and_stop.php
Created October 15, 2018 13:00 — forked from ideadude/my_change_pmpro_sessions_start_and_stop.php
Change when Paid Memberships Pro starts and stops PHP sessions.
<?php
/**
* Change when Paid Memberships Pro starts and stops PHP sessions.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_change_pmpro_sessions_start_and_stop() {
// make sure PMPro has loaded
if( !function_exists( 'pmpro_start_session' ) ) {
return;
}
@greathmaster
greathmaster / pmpro_ld2aff.php
Last active March 27, 2018 22:10 — forked from strangerstudios/pmpro_ld2aff.php
Link Paid Memberships Pro discount codes to affiliate accounts from another plugin/service.
/*
Link discount codes to affiliates.
*/
//this is the parameter we're looking for to find affiliates... based on which plugin/etc you are using
//define('PMPRO_LDC2AFF_KEY', 'wpam_id'); //Affiliates Manager Plugin
define('PMPRO_LDC2AFF_KEY', 'pa'); //WordPress Lightweight Affiliates
//define('PMPRO_LDC2AFF_KEY', 'ref'); //AffiliateWP
//helper function to get the values from options and make sure they are an array
function pmpro_ld2aff_getOptions() {