Skip to content

Instantly share code, notes, and snippets.

View berniechiu's full-sized avatar
:octocat:
Chase Excellence, Success will Follow

Bernie Chiu berniechiu

:octocat:
Chase Excellence, Success will Follow
View GitHub Profile
require 'cgi'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secret_key_base)
config = Rails.application.config
cookie = CGI::unescape(cookie)
salt = config.action_dispatch.authenticated_encrypted_cookie_salt
encrypted_cookie_cipher = config.action_dispatch.encrypted_cookie_cipher || 'aes-256-gcm'
# serializer = ActiveSupport::MessageEncryptor::NullSerializer # use this line if you don't know your serializer
serializer = ActionDispatch::Cookies::JsonSerializer
require_dependency Rails.root.join('app/models/platform_api/sync_service/error_handlers')
module PlatformApi
module SyncService
class ProductsSync
BATCH_IMPORT_CONFIG = {
on_duplicate_key_update: {
conflict_target: [:identifier, :platform_product_id, :company_id, :store_id],
columns: [:name, :length, :width, :height, :weight, :cost_price, :cost_price_currency, :selling_price, :selling_price_currency, :image_url]
},
@berniechiu
berniechiu / funny-code-01.rb
Created September 17, 2019 10:26
funny-code-01
def do_something_with_keys(params)
do_something(params).keys
end
@berniechiu
berniechiu / prepare-commit-msg
Created August 25, 2019 09:50 — forked from tomohung/prepare-commit-msg
git/hooks/prepare-commit-msg add branch name
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".