Skip to content

Instantly share code, notes, and snippets.

@jonathanstanley
jonathanstanley / rsync-fortrabbit.sh
Last active July 23, 2019 20:12
Enable DELETE on fortrabbit Universal Apps
#!/bin/sh
# This script has 2 lines of fast code to resolve an issue with fortrabbit "universal" apps for PHP sites, but could be used for others.
# For background, see https://help.fortrabbit.com/git-deployment#toc-git-deployment-vs-universal-apps
# On reading that, I expected "overwrite but not delete" strategy meant files outside git would not be deleted.
# However it literally means a committed delete will not be deleted.
# In other words, if you change a file to be empty, it's nullified on push. But if you delete, nothing happens on push; could leave insecure code on your server.
# fortrabbit does not place the .gitignore but rsync requires it, so push it up
scp ~/SOURCEDIR/.gitignore [email protected]:~
@jonathanstanley
jonathanstanley / rebaseCurrency.js
Last active June 4, 2023 18:41
Convert between zero-decimal (integer) and decimal number for currency (for Stripe / Shopify / etc)
/**
* https://shopify.dev/docs/api/ajax/reference/product
* https://stripe.com/docs/currencies#zero-decimal
*/
function rebaseCurrency(
/** @type {number} */ price,
/** @type {string} */ isoCurrency,
/** @type {"toZeroDecimal" | "fromZeroDecimal"} */ transform
) {
const zeroDecimalCurrencies = [