Skip to content

Instantly share code, notes, and snippets.

@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"],
@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 / 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 / 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 / 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 / db_backup.rb
Created November 14, 2020 00:48 — forked from ahmadhasankhan/db_backup.rb
MySQL DB backup script in Ruby CMD
#1===========First code================
#!/usr/bin/env ruby
databases = {
:local_db => {
:database => 'my_db',
:username => 'root',
:password => 'admin',
:host => 'localhost'
@yfkhar
yfkhar / routes.rb
Created July 1, 2021 10:13 — forked from pixeltrix/routes.rb
Examples of advanced Rails 3.0 routes
Rails.application.routes.draw do
get '/(:locale)/products/(:category)/(page/:page).:extension',
:to => 'products#index',
:as => :products,
:constraints => {
:locale => /[a-z]{2}/,
:category => /.+?/,
:page => /\d+/
},
@yfkhar
yfkhar / install-clamav-osx.md
Created July 27, 2021 05:23 — forked from gagarine/install-clamav-osx.md
Howto Install clamav on OSX with brew

Howto Install clamav on OSX with brew

$ brew install clamav
$ cd /usr/local/etc/clamav
$ cp freshclam.conf.sample freshclam.conf

Open freshclam.conf and comment the "Example" (in new version it may be "FooClam") line:

@yfkhar
yfkhar / how-to-git-patch-diff.md
Created October 5, 2021 21:32 — forked from nepsilon/how-to-git-patch-diff.md
How to generate and apply patches with git? — First published in fullweb.io issue #33

How to generate and apply patches with git?

It sometimes happen you need change code on a machine from which you cannot push to the repo. You’re ready to copy/paste what diff outputs to your local working copy.

You think there must be a better way to proceed and you’re right. It’s a simple 2 steps process:

1. Generate the patch:

git diff > some-changes.patch