Skip to content

Instantly share code, notes, and snippets.

View LarryUllman's full-sized avatar

Larry Ullman LarryUllman

  • State College, PA
View GitHub Profile
@LarryUllman
LarryUllman / insights_table.md
Last active January 25, 2024 19:58
Insights example

Insights example

The table presents a sequence of events for a PR from creation to merge. Note that the stats are only computed when the PR is merged, not at each individual step.

Event Step Insights impact
1 Author creates a PR in draft state that adds 10 lines of code and deletes 5 lines of code Lines of code added increases by 10 for Author; lines of code deleted increase by 5 for Author
2 Author publishes the PR, making it ready for review Starts the virtual timer for publish to merge time calculation
3 Author requests reviews from three people Starts the virtual timer for response time calculation
4 Reviewer A requests changes on the PR PRs reviewed increases by 1 for Reviewer A; Reviewer A response time = time at event 4 - time at event 3; wait time until first review for Author = time at event 4 - time at event 2
@LarryUllman
LarryUllman / gist:fbe8db2f1ecc6c92e74a
Created July 23, 2014 14:49
Stripe - Calculate Subscription Proration
proration cost = (period end - API request time) / (period end - period start) * quantity * plan price
@LarryUllman
LarryUllman / gist:b3cf527b0a864d6921aa
Last active August 29, 2015 14:04
Stripe - PHP - Upgrade Subscription Plan, Invoice Now
// Retrieve the customer:
$customer = Stripe_Customer::retrieve($customer_id);
// Retrieve the subscription being updated:
$subscription = $customer->subscriptions->retrieve($subscription_id);
// Change the plan:
$subscription->plan = '25_monthly'; // Was 10_monthly
// Use proration (default; not required):
@LarryUllman
LarryUllman / gist:0db8a6c5a9ec355c0ccb
Created July 23, 2014 13:43
Stripe - PHP - Upgrade Subscription Plan
// Retrieve the customer:
$customer = Stripe_Customer::retrieve($customer_id);
// Retrieve the subscription being updated:
$subscription = $customer->subscriptions->retrieve($subscription_id);
// Change the plan:
$subscription->plan = '25_monthly'; // Was 10_monthly
// Use proration (default; not required):
@LarryUllman
LarryUllman / gist:2b2939245b92a1d1eb96
Last active September 8, 2020 09:53
Stripe - PHP - Update Subscription
// Retrieve the customer:
$customer = Stripe_Customer::retrieve($customer_id);
// Retrieve the subscription being updated:
$subscription = $customer->subscriptions->retrieve($subscription_id);
// Change the subscription settings:
$subscription->trial_end = strtotime('first day of next month 12:00');
// Save the changes:
@LarryUllman
LarryUllman / gist:76b45e6d2ea79001ac87
Last active August 29, 2015 14:04
Stripe - PHP - Create customer with Subscription, No Trial
// Create a customer, subscribe them to a plan, with NO trial:
$cu = Stripe_Customer::create(array(
'email' => $email,
'card' => $token,
'plan' => '10_monthly_trial',
'trial_end' => 'now', // Trial ends now (i.e., no trial)
)
);
@LarryUllman
LarryUllman / gist:86b67f3f3b7e969604c8
Created July 23, 2014 03:17
Stripe - PHP - Create Customer with Subscription
// Create a customer, subscribe them to a plan, with a 7 day trial:
$cu = Stripe_Customer::create(array(
'email' => $email,
'card' => $token,
'plan' => '10_monthly'
'trial_end' => time() + (7 * 24 * 60 * 60), // 7 days
)
);
@LarryUllman
LarryUllman / gist:99a3d43d12dddd0cb1b6
Last active August 29, 2015 14:04
Stripe - PHP - Set API Version
// Mmmmmm...Composer for the Stripe PHP library:
require_once('./vendor/autoload.php');
// Set your API key:
Stripe::setApiKey('sk_test_whatever');
// Set the API version to use for these transactions:
Stripe::setApiVersion('2014-06-17');