Skip to content

Instantly share code, notes, and snippets.

View ionatan-israel's full-sized avatar
🏠
Working from home

Jonatan Rodríguez ionatan-israel

🏠
Working from home
View GitHub Profile
@ionatan-israel
ionatan-israel / update_user_meta.php
Created May 10, 2017 20:21 — forked from JudeRosario/update_user_meta.php
Update user meta when a payment has been made
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' );
}
@ionatan-israel
ionatan-israel / code.php
Created May 4, 2017 09:12 — forked from bappi-d-great/code.php
Assigning another membership based on first registered membership
<?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;
@ionatan-israel
ionatan-israel / code.php
Created May 4, 2017 09:12 — forked from bappi-d-great/code.php
Remove role and assign subscriber role to the user or membership cancel
<?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.
*/
@ionatan-israel
ionatan-israel / cuter.py
Created October 13, 2016 06:57 — forked from sigilioso/cuter.py
Python PIL Example: get a thumbnail by resizing and cropping an image.
# -*- 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.
@ionatan-israel
ionatan-israel / gist:108e1f792de37750141caed5ffda854b
Created May 3, 2016 17:51 — forked from Atem18/gist:4696071
Tutorial to seting up a django website in production.

Set up Django, Nginx and Gunicorn in a Virtualenv controled by Supervisor

Steps with explanations to set up a server using:

  • Virtualenv
  • Virtualenvwrapper
  • Django
  • Gunicorn
@ionatan-israel
ionatan-israel / gitflow-breakdown.md
Created April 30, 2016 01:20 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@ionatan-israel
ionatan-israel / osx-homebrew-setup.md
Created October 7, 2015 07:59 — forked from sr75/osx-homebrew-setup.md
Mac Yosemite OSX - Homebrew (RVM/MySQL/Redis) setup

Mac Homebrew (RVM/MySQL/Redis) setup

Follow the steps below to setup a local development environment:

XQuartz

Recommended to download latest XQuartz

iTerm2

@ionatan-israel
ionatan-israel / atom packages
Last active September 8, 2015 17:46 — forked from focusaurus/atom packages
Atom text editor setup 2015-01-12
atom-beautify
atom-color-highlight
autoclose-html
autocomplete-plus
git-blame
git-plus
jsdoc
jsformat
language-docker
language-dockerfile
@ionatan-israel
ionatan-israel / rounding_decimals.md
Last active August 29, 2015 14:26 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

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.

Original Value

@ionatan-israel
ionatan-israel / dynamic-formset.js
Last active August 29, 2015 14:26 — forked from jteso/dynamic-formset.js
Dynamically adding forms to a formset with jQuery in Django
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());