Skip to content

Instantly share code, notes, and snippets.

View remy727's full-sized avatar
🏠
Working from home

Remy Wang remy727

🏠
Working from home
  • Independent. Hire me!
View GitHub Profile
@remy727
remy727 / detect-presence-of-theme-app-embed-block.rb
Created February 5, 2025 09:43
Detect the presence of theme app embed block in Ruby
module ShopifyApiWrapper
class Theme
class << self
def app_embed_activated?(session:, theme_app_extension_id:)
new(session: session)
.app_embed_activated?(theme_app_extension_id: theme_app_extension_id)
end
end
def initialize(session:)
@remy727
remy727 / remove-shop-specific-webhooks.rb
Created January 27, 2025 19:54
Remove Shop-specific webhooks
# Shop-specific webhooks need to be deleted before migration into App-specific webhooks
# Unless they will be triggered twice
require "mongo"
require "shopify_api"
def remove_webhook(shopify_domain, access_token)
# Get webhook
query = <<~GRAPHQL
query {
@remy727
remy727 / rails_colored_logging.rb
Created September 14, 2024 16:28
Rails Colored Console Logging Examples
# Red
Rails.logger.info "\e[31m[Error] Something went wrong\e[0m"
# Green
Rails.logger.info "\e[32m[Success] Operation completed\e[0m"
# Yellow
Rails.logger.info "\e[33m[Warning] Approaching limit\e[0m"
# Blue
@remy727
remy727 / detect-shopify-app-embed-blocks.rb
Last active May 30, 2024 16:47
Detect app embed blocks in Shopify Theme in Rails
# Documentation: https://shopify.dev/docs/apps/build/online-store/theme-app-extensions/configuration#detecting-app-blocks-and-app-embed-blocks
module ShopifyApiWrapper
class Theme
class << self
def app_embed_activated?(session:, theme_app_extension_id:)
new(session: session)
.app_embed_activated?(theme_app_extension_id: theme_app_extension_id)
end
end
@remy727
remy727 / get-country-name-from-country-code.js
Created February 11, 2024 12:54
Get Country name from Country code using JavaScript
const regionNames = new Intl.DisplayNames(
['en'], {type: 'region'}
);
console.log(regionNames.of('US')); // 👉️ "United States"
console.log(regionNames.of('GB')); // 👉️ "United kingdom"
console.log(regionNames.of('DE')); // 👉️ "Germany"
console.log(regionNames.of('AU')); // 👉️ "Australia"
@remy727
remy727 / app-proxy-verification-concern.rb
Created January 30, 2024 18:32
App Proxy Verification
module AppProxyVerification
extend ActiveSupport::Concern
included do
skip_before_action :verify_authenticity_token, raise: false
before_action :verify_request
end
private
@remy727
remy727 / retrieve-shopify-app-uninstall-surveys.rb
Last active January 5, 2024 19:12
Retrieve Shopify App uninstall surveys
org_id = 'your_org_id'
access_token = 'your_partner_api_access_token'
api_version = 'shopify_api_version' # example: '2024-01'
app_id = "gid://partners/App/your_app_id"
occurred_at_min = 'specific_time' # example: '2024-01-02T23:15:27.000000Z'
uri = URI("https://partners.shopify.com/#{org_id}/api/#{api_version}/graphql.json")
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
@remy727
remy727 / detect-the-client-s-device-using-shopify-app-bridge-utilities.js
Created November 6, 2023 09:35
Detect the client's device using Shopify App Bridge Utilities
import {
isShopifyEmbedded,
isMobile,
isShopifyMobile,
isShopifyPOS
} from '@shopify/app-bridge/utilities';
const onShopifyEmbedded = isShopifyEmbedded();
const onMobile = isMobile();
const onShopifyMobile = isShopifyMobile();
@remy727
remy727 / rails-timezone-list.json
Last active September 5, 2023 19:26
Rails timezone list JON
[
{
"label": "(UTC-12:00) Etc/GMT+12",
"rails_timezone": "International Date Line West",
"tzinfo_identifier": "Etc/GMT+12"
},
{
"label": "(UTC-11:00) Pacific/Pago_Pago",
"rails_timezone": "American Samoa",
"tzinfo_identifier": "Pacific/Pago_Pago"
@remy727
remy727 / react-polaris-multiple-select-component.js
Created August 15, 2023 16:33
React Polaris multiple select component
import {
useCallback,
useState,
} from "react";
import {
Button,
Checkbox,
Collapsible,
Icon,
Modal,