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 / core.cljs
Created April 10, 2020 22:06
ClojureScript: Hidde flash message after 4 seconds
(defn ^:export flash-timeout []
(when-let [flash-msg (gdom/getElement "flash-msg")]
(js/setTimeout #(set! (.-className %) "css-hidden-class") 4000 flash-msg)))
;; In a new hotel containing 100 rooms, Tom was hired to paint the numbers from 1-100 on the doors.
;; How many times will Tom have to paint the number 8?
(get (frequencies (clojure.string/join (range 101))) \8)
@aarkerio
aarkerio / profiles.clj
Last active May 11, 2020 17:03
Connect cider with Luminus (May/2020)
I tried following the Cider docs but I was getting the message:
Wrong number of arguments: (4 . 4), 0
Error from syntax checker clojure-cider-eastwood: Done with no errors
Anyhow I could fix it, the next should work:
;; My file in $HOME/.lein/profiles.clj.
{:user {
:dependencies [
@aarkerio
aarkerio / graphql.rb
Created August 25, 2020 15:52
Shopify GraphQL API. Search products and its variants
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
@aarkerio
aarkerio / shop_request_spec.rb
Last active October 27, 2020 16:38
Shopify request test
# 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]
@aarkerio
aarkerio / support_request_spec.rb
Last active May 3, 2021 19:27
Rails rspec shopify login
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!
@aarkerio
aarkerio / offer.rb
Created May 18, 2021 17:33
Group and order array by frequency
# 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
@aarkerio
aarkerio / flatpickr.html
Created May 21, 2021 19:39
If flatpickr doesn't work, this is a minimal example.
<!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>
@aarkerio
aarkerio / ip.sh
Created July 16, 2021 05:25
Heroku Postgresql upgrade
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
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: