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 / .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() {
@greathmaster
greathmaster / elementor_compatibility_for_pmpro.php
Created March 27, 2018 16:02 — forked from kimcoleman/elementor_compatibility_for_pmpro.php
Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder.
<?php
/**
* Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder:
* https://wordpress.org/plugins/elementor/
*
* You must also set a Custom Field on the Membership Checkout page with the key
* 'pmpro_default_level' and value of a level ID in order to properly design your
* Membership Checkout page using Elementor.
*/
function elementor_compatibility_for_pmpro() {
@greathmaster
greathmaster / gist:b49b8fad921b95a462bcc4267beb5366
Created January 4, 2018 22:39 — forked from andrewlimaza/pmpro-edit-other-emails.php
Stop PMPro from editing other WordPress email formats
remove_filter( 'wp_mail_content_type', 'pmpro_wp_mail_content_type' );