Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@joshuapaling
joshuapaling / heroku-connect.md
Last active June 15, 2020 00:52
Changing Heroku Connect without breaking prod

How to not make mistakes with Heroku Connect

A recent issue was caused by a PR promoted to prod before the necessary Heroku Connect changes were made on prod (they were correctly made on test). It's #82 in the RCA log

Tim flagged that this has happened several times in the past (though not recorded in RCA log). Can we prevent it in future?

Why it's a hard problem

As per Joel Test - 2. Can you make a build in one step?, "If the process takes any more than one step, it is prone to errors".

How promo refunds work now

See https://github.com/brandsExclusive/svc-payment/pull/584

When a customer buys a $100 item with a 10% promo discount, the customer sees it as "I only paid $90". But our system sees it as "The customer paid $100 total, made up of $90 stripe, and $10 promo". The "promo" is just another payment type, like credits, stripe, paypal, razorpay, etc. And the "promo" payment type is thought of as "cash spent by the marketing team on advertising to the customer who used the promo".

Promo payments are never refunded. Users of course don't care about this (they were never aware of the hidden "promo" payment they made), but our books do.

If you refund a full item, the full amount (excluding promo payments) is refunded. If you do a partial refund, we leave it to the admin to ensure they're refunding the right amount - considering promos. But if a $100 order has a $10 promo, you can never refund more than $90.

For order https://admin.luxuryescapes.com/purchases/8e254fcc-de48-40e8-9e2f-cbeb4919a75d

There's 2 stripe payments:

  1. $5,072 => covers $2323 in flights and $2749 for package
  2. $130 => covers airport lounge add-on

Refund steps taken were:

  1. Through our admin portal, someone refunded the full $2749 for the package.
  2. Payment service looked at the stripe payments and said "ok, we can refund $2749 by refunding the full $130 payment, plus $2619 of the $5072 payment". (This is a bug we can fix - it should have taken the whole $2749 from the $5072 payment!)
@joshuapaling
joshuapaling / upgrade.sh
Created June 5, 2019 10:27
upgrade packages only if your tests pass
declare -a packages=(
"node-sass"
"react-qr-reader"
"moment-timezone"
"qs"
)
for i in "${packages[@]}"
do
# Here's the code that's a candidate for refactor, I'm just trying
# to get a sense of if dry monads are a good fit or if this isn't really
# complex or nested-ifs enough to make it really worth it.
# I'm more just checking out dry monads for fun (and potential profit!) rather than
# trying to solve an immediate pain point.
#
# Context is: it's an Employee Relationship Management system.
# Employees earn points for doing things. Periodically, the company holds
# a "flash sale" where they can redeem those points for rewards.
#
"the products actually already live in our point of sale system"
Does "live" in this context rhyme with "div" or "dive"? Let's call the "div" version of it "liv" to clarify.
This makes sense: "the products actually already liv in our point of sale system". It means that there are many products, and the place they live/belong is "in our point of sale system".
This also makes sense: "the product's actually already live in our point of sale system". It means there is one product, and it's already "live" (aka deployed or whatever) in our point of sale system.
The rules are:
- NEVER have an apostrophe for plurals
Answer to https://twitter.com/saronyitbarek/status/760853206205292545
If you code (or learning!), do you use a journal/notebook/todo list for code-related tasks/planning?
I always have scrap paper on my desk. I intentially make it scrap, already printed on one side paper, so I don't feel even a tiny bit bad about using it. I'll write ToDos on it when I want them to physically be right in front of me till they get done. I'll also doodle on it when struggling with a concept, when that can help.
I use digital flash cards. When I come across a term I don't know, but want to, I put it in there. I use http://ankisrs.net/, specifically. I could give a whole talk on digtal flash cards, how good they are, and how to use them effectively. TL;DR: They are SO good. To be effective, go through them every day. Keem them short - a word or two on the front, a short sentence or 2, max, on the back. Be selective about which things you want to commit to memory - you have finite space. Focus on concepts, not language syntax.
class Fixnum
def to_roman
# Roman numeral problem described in Sandi Metz's newsletter:
# http://us3.campaign-archive2.com/?u=1090565ccff48ac602d0a84b4&id=24e2bac263&e=6df8a5006fa
# You don't need conditionals, and you don't need two steps either.
# The trick: there's nothing special about the subtractive cases.
# Treat them as a single numeral that just happens to be two
# characters rather than one.
all_numerals = {
'I' => 1,
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.box {
width: 300px;
height: 300px;
float: left;
border: 9px solid red;