This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('ms_gateway_cancel_membership', 'm2_delete_user', 999, 1) ; | |
function m2_delete_user( $sub ) { | |
wp_delete_user( $sub->user_id ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM public.cities, | |
unnest(zip_codes) zip | |
WHERE lower(zip) LIKE '08411%'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$api = ms_api(); | |
$member = $api->get_current_member(); | |
| |
// Check if current user is in certain membership: | |
$membership_id = 100; // hardcode the ID. | |
$membership_id = $api->get_membership_id( 'premium' ); // fetch by membership name. | |
if ( $member->has_membership( $membership_id ) ) { | |
echo "You are member of " . $membership_id; | |
} | |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loging( $obj ) { | |
ob_start(); | |
var_dump( $obj ); | |
error_log(ob_get_clean()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/ | |
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch | |
// async function | |
async function fetchAsync () { | |
// await response of fetch call | |
let response = await fetch('https://api.github.com'); | |
// only proceed once promise is resolved | |
let data = await response.json(); | |
// only proceed once second promise is resolved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edito /etc/hosts | |
192.168.0.100 frontend.test | |
192.168.0.101 backend.test | |
# Asigno alias a lo0 | |
sudo ifconfig lo0 192.168.0.101 alias | |
sudo ifconfig lo0 192.168.0.100 alias | |
# sudo nano /etc/pf.anchors/development.forwarding | |
rdr pass on lo0 inet proto tcp from any to 192.168.0.100 port 80 -> 127.0.0.1 port 3000 |