Steps with explanations to set up a server using:
- Virtualenv
- Virtualenvwrapper
- Django
- Gunicorn
# -*- 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. |
<?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. | |
*/ |
<?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; |
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' ); | |
} |
add_action('ms_gateway_cancel_membership', 'm2_delete_user', 999, 1) ; | |
function m2_delete_user( $sub ) { | |
wp_delete_user( $sub->user_id ); | |
} |
$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; | |
} | |
|
// 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 |
# Boot to recovery mode and disable system integrity protection | |
csrutil disable | |
# Reboot to regular mode and purge these motherfuckin plists | |
sudo rm -f /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources/*.plist | |
# Reboot to recovery mode and enable system integrity protection | |
csrutil enable | |
# Reboot |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)