Skip to content

Instantly share code, notes, and snippets.

View aarkerio's full-sized avatar
🐵
Echando rostro en Ixtapa.

Manuel Montoya aarkerio

🐵
Echando rostro en Ixtapa.
View GitHub Profile
@aarkerio
aarkerio / mv.sql
Created August 26, 2022 18:46
PGSQL Materialized view
CREATE MATERIALIZED VIEW products_shopify_ids_on_active_shops AS
SELECT shopify_domain, array_agg(col ORDER BY col) AS product_shopify_ids
FROM (
SELECT DISTINCT
shops.shopify_domain AS shopify_domain,
unnest(offers.offerable_product_shopify_ids) AS col
FROM shops
INNER JOIN offers
ON shops.id = offers.shop_id
INNER JOIN subscriptions
@aarkerio
aarkerio / set_heroku_vars.rb
Last active March 6, 2023 17:14
set_heroku_vars
require 'json'
raw_data = File.read('prod_vars.json')
# {"ASSET_HOST": "https://foo.cloudfront.net", }
vars_info = JSON.parse(raw_data);
puts "### vars_info ###>> #{vars_info.inspect}"
@aarkerio
aarkerio / donations_controller_spec.rb
Last active July 2, 2023 18:40
Rails 6 Rspec: Validates json web token API request with signed cookie
# frozen_string_literal: true
RSpec.describe Api::V2::DonationsController, type: :request do
let(:donor) { Fabricate(:donor) }
before do
cookies = ActionDispatch::Request.new(Rails.application.env_config.deep_dup).cookie_jar
@tmp = cookies.signed[:donor_jwtapi] = { value: { token: donor.token} , httponly: true }
end