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
@aarkerio
aarkerio / install matching chrome driver.txt
Created January 8, 2025 19:08
Install matching chrome and chromedriver
1) Check your current chrome version:
$ google-chrome --version
Google Chrome 131.0.6778.264
2) Download the chromedriver for your version:
$ npx @puppeteer/browsers install [email protected]
@aarkerio
aarkerio / auth0_authentication_helper.rb
Last active January 22, 2025 18:56
auth0 devise rspec authentication helper
def login_auth0(user)
OmniAuth.config.test_mode = true
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
opts = {
provider: 'auth0',
uid: user.auth0_id,
info: {
email: user.email,
Query to get the last one:
db.fundraisers.find().sort({'_id': -1}).limit(1)
Result:
[
{
_id: ObjectId("6769c7c016906665787708e1"),
event_name: 'RHA Gala',