Skip to content

Instantly share code, notes, and snippets.

View bittu-choudhary's full-sized avatar

Bittu Choudhary bittu-choudhary

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
@bittu-choudhary
bittu-choudhary / exporter.js
Created June 10, 2020 10:11
Google App Script - Export google sheet to JSON file and save it on google drive.
/**
* onOpen adds Export JSON option in spreadsheet tool bar
* exportJSON prepares json from sheet, save it in same folder as of spreadsheet on google drive and display it in modal with download link
* turn on Drive API on script editor, Resources -> Advanced Google Services -> Drive API
*/
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Run",