Skip to content

Instantly share code, notes, and snippets.

View ignacio-chiazzo's full-sized avatar
👋
wave

Ignacio Chiazzo Cardarello ignacio-chiazzo

👋
wave
View GitHub Profile
# Gem
module PricingEngine
class Engine
#...
# Calculates the price for variants given the buyer context.
#
# @param context [Schema::BuyerContext] the buyer context
#
# @return [Array<PricingEngine::Schema::Price>] An array of prices for the context passed.
def calculate_prices_for_variants(context)
PriceCalculation Example Gist: https://gist.github.com/ignacio-chiazzo/47f19baf6591525da83620647fb0f862
Pricing Schema Gist https://gist.github.com/ignacio-chiazzo/83898d53528a502e217463bbb3dd5c91
Consumer 1 Logic https://gist.github.com/ignacio-chiazzo/677bb5797160c2d06659747f36240900
Consumer 2 Logic https://gist.github.com/ignacio-chiazzo/7e51ff0bb4b6d1a0fb445181453e3d47
Price Calculation Gem https://gist.github.com/ignacio-chiazzo/6da5081ae978840ebf2b64c358a432ff
`GET /products?limit=20&page=1` # -> Returns the **first Page**
`GET /products?limit=20&page=2` # -> Returns the **second Page**
`GET /products?limit=20&page=3` # -> Returns the **third Page**
`....`
`....`
SELECT *
FROM products
ORDER BY Id
LIMIT 20
OFFSET 200;
SELECT *
FROM products
ORDER BY Id
LIMIT 20
OFFSET 200;
GET https://{shop}.myshopify.com/admin/api/products.json?limit=3  # page 1

#... Response Header 
Link: "<https://{shop}.myshopify.com/admin/api/2019-07/products.json?page_info=hijgklmn&limit=3>; rel=next"
#...


GET https://{shop}.myshopify.com/admin/api/2019-07/products.json?page_info=hijgklmn&limit=3   # page 2
https://api.stripe.com/v1/charges?limit=3 # page 1
https://api.stripe.com/v1/charges?starting_after=prod_GscR7tGwKBwJ6C&limit=3 # page 2
https://api.stripe.com/v1/charges?starting_after=prod_GscR7tAbCDewJ1&limit=3 # page 3
SELECT *
FROM products
WHERE ID > <since_id_param>
ORDER BY ID ASC
LIMIT 100
type __Schema {
types: [__Type!]!
queryType: __Type!
mutationType: __Type
subscriptionType: __Type
directives: [__Directive!]!
}
@ignacio-chiazzo
ignacio-chiazzo / HeapSort.sj
Last active December 10, 2018 16:13
Implement Heap Sort in JS
// Testing Gist
var heapSort = function(arr) {
var n = arr.length;
for(var i = Math.floor(n/2) - 1; i >= 0; i--)
heapify(arr, n, i);
for(var i = n - 1; i >= 0; i--) {
swap(arr, 0, i);
heapify(arr, i, 0);
}