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
@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".