1. Limit (cost=2601.98..2602.12 rows=19 width=12) (actual=7484.945..8923.432 rows=57 loops=1) 0.01 ms 8923.432 ms ↓ 3 57 19 1
2. Unique (cost=2601.98..2602.12 rows=19 width=12) (actual=7484.943..8923.423 rows=57 loops=1) 617.708 ms 8923.423 ms ↓ 3 57 19 1
3. Sort (cost=2601.98..2602.03 rows=19 width=12) (actual=7484.943..8305.716 rows=18188180 loops=1) 4130.549 ms 8305.716 ms ↓ 957272.64 18188180 19 1
4. Nested Loop Left Join (cost=3.44..2601.58 rows=19 width=12) (actual=0.156..4175.168 rows=18188180 loops=1) 692.751 ms 4175.168 ms ↓ 957272.64 18188180 19 1
5. Nested Loop Left Join (cost=3..2554.34 rows=5 width=12) (actual=0.145..884.039 rows=1299189 loops=1) -16.11 ms 884.039 ms ↓ 259837.8 1299189 5 1
6. Nested Loop Left Join (cost=2.57..2517.42 rows=4 width=12) (actual=0.133..112.587 rows=787562 loops=1) 28.781 ms 112.587 ms ↓ 196890.5 787562 4 1
7. Nested Loop Left Join (cost=2.15..2500.85 rows=4 width=12) (actual=0.12..26.704 rows=19034 loops=1) -1.817 ms 26.704 ms ↓ 4758.5 19034 4 1
8. Nested Loop L
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"batch_request_id": "Sannam-x13", | |
"batch_update_url": "https://client-api-domain.com/batch_status_update/", | |
"operations": [ | |
{ | |
"body": { | |
"data": [ | |
{ | |
"user_id": "1234567", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Postmark::ApiInputError: Invalid 'Subject' value. It should be less than 2000 characters in length. | |
Postmark::UnexpectedHttpResponseError: The Postmark API responded with HTTP status 404. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select patient_histories.*, patients.* from patients join patient_histories on patient_histories.id = ( | |
select id from patient_histories | |
where patient_histories.patient_id = patients.id | |
order by patient_histories.id asc | |
limit 1 | |
) | |
/*where patients.gender="female"*/ | |
/*and patient_histories.year="2076" and patient_histories.month="8" and patient_histories.day="19"*/ | |
/*https://www.periscopedata.com/blog/4-ways-to-join-only-the-first-row-in-sql)*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TEMPORARY TABLE IF EXISTS patient_visits; | |
CREATE TEMPORARY TABLE patient_visits LIKE patients; | |
INSERT INTO patient_visits | |
SELECT * | |
FROM patients | |
WHERE id | |
IN ( | |
SELECT patient_id | |
FROM patient_histories | |
GROUP BY patient_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res = Patient.find_by_sql(%{ | |
select id from ( | |
select | |
patients.id as id, | |
patient_histories.year as year, | |
patient_histories.month as month, | |
patient_histories.day as day | |
from patients | |
join patient_histories | |
on patients.id=patient_histories.patient_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.qry | |
res = Patient.find_by_sql(%{ | |
select * from ( | |
select | |
patients.id as id, | |
patient_histories.year as year, | |
patient_histories.month as month, | |
patient_histories.day as day | |
from patients | |
join patient_histories |
- SCA: Strong Customer Authentication
- off-session payments: We can make payments when customer is offline (example: recurring payments for our subscription) for this we need to flag first time payment with SCA and pass that in API.
- recovery flow: While Stripe requests exemptions to reduce the need for customer reauthentication, there is always a risk that the cardholder’s bank will reject the exemption request. We should always build a recovery flow to bring a customer back on-session in case they need to authenticate again.
- Flagging subsequent transactions. Any payment made with a saved card when a user is off-session must be marked accordingly, with reference to the first authenticated transaction. Stripe handles this for you.
- Mandate collection. A mandate represents the agreement you have with the customer on how you plan to use their card in the future. In your checkout flow, add some consent tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id": 28, "iso_code": "BWP", "iso_numeric": "072", "name": "Botswana Pula", "symbol": "P", "html_entity": "", "subunit": "Thebe", "subunit_to_unit": 100, "smallest_denomination": 5, "created_at": "2015-01-01T04:21:55.495-06:00", "updated_at": "2019-06-14T09:39:52.383-05:00"}, {"id": 14, "iso_code": "AWG", "iso_numeric": "533", "name": "Aruban Florin", "symbol": "ƒ", "html_entity": "ƒ", "subunit": "Cent", "subunit_to_unit": 100, "smallest_denomination": 5, "created_at": "2015-01-01T04:21:55.439-06:00", "updated_at": "2019-03-22T09:43:17.098-05:00"}, {"id": 16, "iso_code": "BAM", "iso_numeric": "977", "name": "Bosnia and Herzegovina Convertible Mark", "symbol": "КМ", "html_entity": "", "subunit": "Fening", "subunit_to_unit": 100, "smallest_denomination": 5, "created_at": "2015-01-01T04:21:55.447-06:00", "updated_at": "2019-03-22T09:43:17.109-05:00"}, {"id": 20, "iso_code": "BHD", "iso_numeric": "048", "name": "Bahraini Dinar", "symbol": "ب.د", "html_entity": "", "subunit": "Fils", "subunit_to_unit": 10 |
NewerOlder