Skip to content

Instantly share code, notes, and snippets.

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

Remy Wang remy727

🏠
Working from home
View GitHub Profile
@remy727
remy727 / App.jsx
Last active February 17, 2025 09:03
Mantle Subscription Issue
import {
AppType,
Provider as GadgetProvider,
useGadget,
} from "@gadgetinc/react-shopify-app-bridge";
import { NavMenu } from "@shopify/app-bridge-react";
import { Page, Spinner, Text } from "@shopify/polaris";
import { useEffect, useMemo } from "react";
import {
Outlet,
@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 / PlansPage.jsx
Created January 24, 2025 18:10
PlansPage
```jsx
import { useMantle } from "@heymantle/react";
import { useEffect } from 'react';
export default function () {
const { createHostedSession } = useMantle();
useEffect(() => {
(async () => {
const session = await createHostedSession({ type: 'plans' });
open(session.url, "_self");
@remy727
remy727 / available_shopify_plan_names
Created December 27, 2024 21:06
Available Shopify plan names
affiliate
trial
basic
professional
unlimited
shopify_plus
staff
staff_business
dormant
npo_full
@remy727
remy727 / plan.tsx
Created October 21, 2024 17:57
shouldRevalidate learning
import { useNavigate } from '@remix-run/react'
import type { ShouldRevalidateFunction } from '@remix-run/react'
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node'
import { Banner, BlockStack, Button, Card, Icon, Modal, Page, Text } from '@shopify/polaris'
import { CheckIcon } from '@shopify/polaris-icons'
import { authenticate } from '../shopify.server'
import { UserService } from '../repository/user.service'
import { json, useActionData, useLoaderData, useSubmit } from '@remix-run/react'
import type { UserInterface } from '../db/user'
import { Level, TestingStore } from '../db/user'
@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
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@remy727
remy727 / telegram-bot-documentation.md
Last active July 26, 2024 11:27
Telegram bot documentation

Tables

Structure

  • What is the relation between credit_transations and payouts? I saw 1:1 on the diagram. If this is correct, can we combine the tables into one?
  • telegram_chats
    • telegram_chat_id - we have both id and telegram_chat_id fields. Can we rename telegram_chat_id field to telegram_id or telegram_message_id? Or rename telegram_chats table to chats or telegram_messages.
    • Do we need text field to store text?
    • Do we need soft delete on this table?
  • telegram_users
@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