Steps with explanations to set up a server using:
- Virtualenv
- Virtualenvwrapper
- Django
- Gunicorn
add_action('ms_gateway_transaction_log', 'update_meta_on_stripe_return' , 999, 8); | |
function update_meta_on_stripe_return( $id, $h, $is_paid, $sub, $iid, $amt, $n, $eid ) { | |
mail('[email protected]', 'TEST', "Was Paid : ".$is_paid); | |
if( $is_paid ) | |
update_user_meta( $sub->user_id, 'some_meta', 'some_value' ); | |
} |
<?php | |
add_action( 'ms_model_relationship_create_ms_relationship_before', 'ms_controller_member_assign_memberships_done_cb', 99, 4 ); | |
function ms_controller_member_assign_memberships_done_cb( $membership_id, $user_id, $gateway_id, $move_from_id ) { | |
$target_membership = ''; | |
switch( $membership_id ){ | |
// if first membership 123 | |
// then assign to 456 | |
case 123: | |
$target_membership = 456; |
<?php | |
add_action( 'ms_model_event', 'my_event_handler', 10, 2 ); | |
/** | |
* Handles an event and process the correct communication if required. | |
* | |
* @param MS_Model_Event $event The event that is processed. | |
* @param mixed $data The data passed to the event handler. | |
*/ |
# -*- coding: utf-8 -*- | |
import Image | |
def resize_and_crop(img_path, modified_path, size, crop_type='top'): | |
""" | |
Resize and crop an image to fit the specified size. | |
args: | |
img_path: path for the image to resize. |
Follow the steps below to setup a local development environment:
Recommended to download latest XQuartz
atom-beautify | |
atom-color-highlight | |
autoclose-html | |
autocomplete-plus | |
git-blame | |
git-plus | |
jsdoc | |
jsformat | |
language-docker | |
language-dockerfile |
In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.
All the examples use demical types, except for the original value, which is automatically casted as a float.
To set the context of what we are working with, let's start with an original value.
function updateElementIndex(el, prefix, ndx) { | |
var id_regex = new RegExp('(' + prefix + '-\\d+)'); | |
var replacement = prefix + '-' + ndx; | |
if ($(el).attr("for")) $(el).attr("for", $(el).attr("for").replace(id_regex, replacement)); | |
if (el.id) el.id = el.id.replace(id_regex, replacement); | |
if (el.name) el.name = el.name.replace(id_regex, replacement); | |
} | |
function addForm(btn, prefix) { | |
var formCount = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val()); |