Skip to content

Instantly share code, notes, and snippets.

View Joseworks's full-sized avatar

Jose C Fernandez Joseworks

View GitHub Profile
@Joseworks
Joseworks / fakeout.rb
Created February 25, 2021 14:25 — forked from matthutchinson/fakeout.rb
fake.rake - a takeout approach and rake task that generates some random fake data for a rails app (using ffaker)
# place this in lib/fakeout.rb
require 'ffaker'
module Fakeout
class Builder
FAKEABLE = %w(User Product)
attr_accessor :report
@Joseworks
Joseworks / 00.md
Created February 25, 2021 14:25 — 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:

class MoveAttachmentsToNewLocation < ActiveRecord::Migration
def initialize(name = self.class.name, version = nil)
access_key = Rails.application.secrets.g3_access_key_id
secret_key = Rails.application.secrets.g3_secret_access_key
storage = Fog::Storage::Google.new google_storage_access_key_id: access_key,
google_storage_secret_access_key: secret_key
@bucket_name = Rails.application.secrets.g3_bucket
@bucket = storage.directories.get(@bucket_name)
super(name, version)
@Joseworks
Joseworks / ruby array #subtract
Created January 27, 2018 18:36 — forked from karatedog/ruby array #subtract
Ruby Array's subtract method which subtracts the values of the elements not the elements themselves
# Ruby Array's "-" (minus) method removes elements from the receiver which exist in the parameter Array
[5, 6, 1] - [2, 3, 5]
# => [6, 1]
# this #subtract method will subtract the value of the parameter Array from the value of the receiver Array, defined by the actual index.
# type mismatch, Nil, and different Array length are not handled
class Array
class Child extends React.Component {
render () {
return (<div>I'm the child</div>);
}
}
class ShowHide extends React.Component {
constructor () {
super ();
this.state = {
@Joseworks
Joseworks / 1.rb
Created December 29, 2017 17:20 — forked from stevegraham/1.rb
Symbol#to_proc
%w(john paul ringo george).map { |p| p.capitalize }
# => ["John", "Paul", "Ringo", "George"]
@Joseworks
Joseworks / OSX UTC Time Zone
Created November 14, 2017 17:23 — forked from nick-desteffen/OSX UTC Time Zone
Set Time zone in OSX to UTC
sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime
@Joseworks
Joseworks / user.rb
Created November 10, 2017 04:51 — forked from harlow/user.rb
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@Joseworks
Joseworks / multiple_ssh_setting.md
Created October 17, 2017 02:13 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@Joseworks
Joseworks / rendering_helper.rb
Created August 10, 2017 15:11 — forked from tylerhunt/rendering_helper.rb
Override Rails' #render helper to fix an issue with rendering partials based on an object within a namespace.
module RenderingHelper
# Override Rails' #render helper to fix an issue with it not honoring objects
# with #to_partial_path definitions that return absolute paths, which is
# problematic when rendering partials within a namespaced controller.
def render(options={}, locals={}, &block)
return super unless options.respond_to?(:to_partial_path)
object = options
path = object.to_partial_path