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 / 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
@remy727
remy727 / install_ngrok.md
Created May 6, 2024 14:19 — forked from russorat/install_ngrok.md
How to install ngrok on linux subsystem for windows
@remy727
remy727 / looking-for-ror-backend-developer.md
Last active March 1, 2024 10:01
Ruby on Rails Backend developer

The Opportunity:

We're hiring Backend Engineers who will be working on Ruby on Rails API apps. But sometimes also work on non-RoR app such as Sinatra or pure Ruby scripts. The developer will be working closely with me.

What you will do:

  • Build RESTful APIs to support our front end team
  • Take care of error handling and fixing real bugs on production
  • Take ownership of the system health, monitoring and performance
@remy727
remy727 / yeti-orders.md
Created February 25, 2024 12:45
API request and response examples sent from Order Split App on Yeti

Y977989-1

API request
{"order": {"name": "Y977989-1", "tags": "braze_block", "email": "[email protected]", "currency": "AUD", "tax_lines": [{"rate": 0.1, "price": 2.27, "title": "GST"}], "total_tax": 2.27, "line_items": [{"id": 13851852701830, "sku": "21071501919", "name": "Rambler® 10 oz (296 ml) Tumbler - Power Pink", "grams": 300, "price": "25.00", "title": "Rambler® 10 oz (296 ml) Tumbler", "duties": [], "vendor": "YETI", "taxable": true, "quantity": 1, "gift_card": false, "price_set": {"shop_money": {"amount": "25.00", "currency_code": "AUD"}, "presentment_money": {"amount": "25.00", "currency_code": "AUD"}}, "product_id": 5137824678022, "properties": [], "variant_id": 40236113854598, "pre_tax_price": "22.73", "variant_title": "Power Pink", "product_exists": true, "total_discount": "0.00", "current_quantity": 1, "pre_tax_price_set": {"shop_money": {"amount": "22.73", "currency_code": "AUD"}, "presentment_money": {"amount": "22.73", "currency_code": "AUD"}},
@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