Skip to content

Instantly share code, notes, and snippets.

@yfkhar
yfkhar / gx_app.rb
Created August 1, 2019 09:40 — forked from jhjguxin/gx_app.rb
Mongoid localized fields, and how use it
# encoding: UTF-8
class GxApp
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Sequence
store_in session: "gxservice"
field :name, type: String, default: "Guanxi.me"
field :version, type: String
@yfkhar
yfkhar / 00.md
Created July 30, 2019 08:51 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@yfkhar
yfkhar / shrine.rb
Created July 25, 2019 01:05 — forked from simoleone/shrine.rb
Async image processing in Shrine
Shrine.plugin :backgrounding
Shrine::Attacher.promote { |data| ShrinePromoteWorker.perform_async(data) }
Shrine::Attacher.delete { |data| ShrineDeleteWorker.perform_async(data) }
@yfkhar
yfkhar / shrine.rb
Created July 24, 2019 20:25 — forked from simoleone/shrine.rb
Configuring Shrine for mass-distribution with S3 and Cloudfront
require "shrine/storage/s3"
base_s3_options = {
access_key_id: Rails.application.credentials.dig(:aws, :access_key_id),
secret_access_key: Rails.application.credentials.dig(:aws, :secret_access_key),
region: 'us-east-1',
bucket: ENV['SHRINE_S3_BUCKET'],
}
cache_s3_options = base_s3_options.merge(
@yfkhar
yfkhar / gist:b3685b5f1a87e88c7dc981a095754952
Created June 28, 2019 10:10 — forked from eikes/gist:5a64b661022c756bd6522ed94770e2a6
List of Ruby on Rails Timezone names and their alias
["Africa/Algiers", "West Central Africa"],
["Africa/Cairo", "Cairo"],
["Africa/Casablanca", "Casablanca"],
["Africa/Harare", "Harare"],
["Africa/Johannesburg", "Pretoria"],
["Africa/Monrovia", "Monrovia"],
["Africa/Nairobi", "Nairobi"],
["America/Argentina/Buenos_Aires", "Buenos Aires"],
["America/Bogota", "Bogota"],
["America/Caracas", "Caracas"],