Skip to content

Instantly share code, notes, and snippets.

@mwhagedorn
mwhagedorn / gemfresh.sh
Created January 26, 2022 19:36
script to calculate project currency
#!/usr/bin/env bash
# shellcheck disable=SC2059
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
CLEAR_LINE='\r\033[K'
@mwhagedorn
mwhagedorn / mornings.scpt
Created February 25, 2019 15:57
Applescript to create a "Do Every Morning" list
(*
Creates a “Start Day” project in OmniFocus.
*)
set theMonthDay to (do shell script "date -v+0d +\"%b-%d\"")
set projectName to "Morning " & theMonthDay
set weekBefore to date (do shell script "date -v+0d +\"%B %d, %Y\"")
set weekBefore's hours to 6

Keybase proof

I hereby claim:

  • I am mwhagedorn on github.
  • I am mwhagedorn (https://keybase.io/mwhagedorn) on keybase.
  • I have a public key ASCH7j_BA3d8CvrUORiAsTu5Aa7NK5lwzA2K6AeplOAT4wo

To claim this, I am signing this object:

The following works great:
sendEmail = () => {
this.setState({ isFetching: true });
const params = { id: this.props.uid };
api().post('/internal/invoices/emails', params)
.then((response) => {
this.props.reload();
this.props.notify('success', response.data.message);
})
@mwhagedorn
mwhagedorn / related_specs.sh
Created July 24, 2017 15:35
list all the spec files that have been commited with a certain file
@mwhagedorn
mwhagedorn / push_6_1.rb
Last active May 31, 2017 17:53
Push billing to June 1
c = Console::PrepareGatewayMigration.new('protectionplan', Time.zone.parse('May 31 2017 5:00pm EST')
before_date = Time.zone.parse('June 1 2017 2:00pm EST')
c.record_original_next_assessment_at(before_date)
c.delay_billing_dates_until(before_date)
c = Console::PrepareGatewayMigration.new('petplus-vpi', Time.zone.parse('May 31 2017 5:00pm EST')
before_date = Time.zone.parse('June 1 2017 2:00pm EST')
c.record_original_next_assessment_at(before_date)
c.delay_billing_dates_until(before_date)
@mwhagedorn
mwhagedorn / gist:4967902af9f250bdd2a7181bd3c9f219
Created September 12, 2016 16:00
errant file in react tutorial
var React = require('react');
var ReactDOM = require('react-dom');
var HelloWorld = React.createClass({
render: function() {
return (
<div>Hello World</div>
);
}
});
@mwhagedorn
mwhagedorn / dunning_spec.rb
Created August 4, 2016 15:42
spec to investigate dunning issues
require 'spec_helper'
describe "Dunning" do
let(:site) { subscription.site }
let(:processing_time) { Chronic.parse("August 1, 2016 12:00 pm EST") }
let(:renewal_time) { subscription.current_period_ends_at + 1.minute }
let(:subscription) { create(:active_subscription) }
let!(:strategy) { create(:dunning_strategy, site: site, name:"my awesome test") }
let!(:day_1) { create(:strategy_step, strategy: strategy, action: 'retry', send_email: true, day_threshold: 1) }
let!(:day_3) { create(:strategy_step, strategy: strategy, action: 'retry', send_email: true, day_threshold: 3) }
@mwhagedorn
mwhagedorn / subscription_spec.rb
Created July 8, 2016 13:07
Failing expectation? wierd
let!(:product) { create(:trial_product, trial_type: "no_obligation") }
let!(:subscription) { create(:trial_subscription, product: product).tap(&:process) }
before do
Timecop.freeze(subscription.current_period_ends_at.utc + 1.minute) do
subscription.process
expect(subscription.state).to eq("trial_ended")
end
end
@mwhagedorn
mwhagedorn / composite_decorator.py
Created October 15, 2015 17:20
an example of nested decorators in python
def composite_decorator(self, func, **kwargs):
'''Create a composite decorator
:return: a composite decorator which applies each decorator defined
in self.url_decorators. Should be like calling one decorator
my_decorator(view_func, dashboard=None, panel=None):
'''
def new_decorator(func, **kwargs ):
for decorator in reversed(self.url_decorators):
func = decorator(func)