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
# 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 |
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
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}" |
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
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 |
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
You already have a Rails app with RVM so, install flycheck Ruby on Emacs 27: | |
1) Add rubocop to your Gemfile and bundle. | |
2) Install flycheck on Emacs and configure: | |
(add-hook 'after-init-hook #'global-flycheck-mode) | |
3) Install RVM package from Melpa and setup: |
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
1) Check your database name | |
heroku pg:info --app incartupsell | grep HEROKU | |
HEROKU_POSTGRESQL_GREEN_URL | |
1) Provision a Follower | |
heroku addons:create heroku-postgresql:standard-2 --follow HEROKU_POSTGRESQL_GREEN_URL --app incartupsell |
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
<!doctype html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script> | |
<title>Examples - flatpickr</title> | |
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.css> | |
</head> | |
<body> | |
<h2>aHUEVO prros!!</h2> |
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
# Private: order companions by frequency. | |
# | |
# orders - Array of hashes. | |
# | |
# Returns Hashmap. | |
def companions(orders) | |
orders.reduce([]) {|acc, o| acc + o[:unique_product_ids]}.group_by(&:itself).transform_values!(&:size) | |
.sort{ |a,b| b.second <=> a.second }.first(15) | |
end |
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 shopify_login(shop) | |
OmniAuth.config.test_mode = true | |
OmniAuth.config.add_mock(:shopify, provider: 'shopify', uid: shop.myshopify_domain, | |
credentials: { token: shop.api_token }) | |
Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:shopify] | |
get "/auth/shopify/callback?shop=#{shop.myshopify_domain}" | |
follow_redirect! |
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
# frozen_string_literal: true | |
require 'rails_helper' | |
RSpec.describe 'ShopsController', type: :request do | |
def login(shop) | |
OmniAuth.config.test_mode = true | |
OmniAuth.config.add_mock(:shopify, provider: 'shopify', uid: shop.myshopify_domain, | |
credentials: { token: shop.api_token }) | |
Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:shopify] |
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
query = %{ { products(first: 20, query: "title:*bik*") | |
{ edges { node { id | |
title | |
priceRange { maxVariantPrice { amount } minVariantPrice { amount } } | |
featuredImage { transformedSrc altText } | |
variants(first:10) { edges { node { id title price } } } } } } } } | |
url = 'https://dev-store-rdigital.myshopify.com/admin/api/2020-07/graphql.json' | |
def api_headers |
NewerOlder