Skip to content

Instantly share code, notes, and snippets.

Avatar

William Wong Garay willywg

View GitHub Profile
@carlosramireziii
carlosramireziii / attached_validator.rb
Last active Dec 21, 2020
A validator and RSpec matcher for requiring an attachment using Active Storage
View attached_validator.rb
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@willywg
willywg / devise_helper.rb
Last active Nov 5, 2016 — forked from seyhunak/devise_helper.rb
Devise Error Messages with Bootstrap 3 style
View devise_helper.rb
# /app/helpers/devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
@zentetsukenz
zentetsukenz / ruby_on_rails_deployment.md
Last active Nov 15, 2021
Deploy Ruby on Rails application with Docker Compose and Capistrano with ease
View ruby_on_rails_deployment.md

Docker

Files and Folders.

|
|\_ app
|...
|\_ docker
| |
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active Nov 30, 2021
Using multiple github accounts with ssh keys
View using-multiple-github-accounts-with-ssh-keys.md

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@erichrobinson
erichrobinson / README.md
Last active Nov 19, 2021
SwitchResX Configuration
View README.md

#SwitchResX Settings for LG 21:9 UltraWide

SwitchResX is a utility that allows users to override the default resolution settings in OSX. For more information, including download links, vist http://www.madrau.com/ .

##Disabling System Integrity Protection (SIP)

If you are running OSX 10.11 or higher, SIP must be disabled. To disable SIP do the following:

  • Boot into the recovery partition by pressing CMD + R when starting up your Mac.
  • Once in recovery mode, open a terminal window.
  • Type the command csrutil disable
@rothgar
rothgar / install-tmux
Last active Jan 29, 2021 — forked from ekiara/how_to_install_tmux_on_centos
Install tmux 1.9 on rhel/centos 6
View install-tmux
# Install tmux on Centos release 6.5
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
View Rails 4 Upgrade Notes.md

Rails 4 Upgrade Notes

I recently completed our upgrade to Rails 4. Below are various notes and links that may help you if you are upgrading your application to Rails 4. YMMV.

Overview

There is a good Rails Guide on upgrading, with a specific section on upgrading from Rails 3.2 to Rails 4.0. First, a bit about our specific application and the technologies used, pre-Rails 4 upgrade:

  • Rails 3.2.14
  • Ruby 2.0.0-p247
@kyletcarlson
kyletcarlson / rspec_model_testing_template.rb
Last active Nov 23, 2021
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@willywg
willywg / image_magick_install_centos_6
Last active Jul 28, 2018
Instalando ImageMagick y rmagick en Centos 6
View image_magick_install_centos_6
1. Desinstalar todo rastro de ImageMagick e ImageMagik-devel
sudo yum remove ImageMagick
sudo yum remove ImageMagick-devel
2. Instalar complementos previos:
sudo yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
3. Bajarse el ImageMagick desde las fuentes:
mkdir ~/sources
cd ~/sources
@jhjguxin
jhjguxin / how_to_concerns.md
Last active Nov 28, 2018 — forked from dhh/gist:1014971
how to concerns with rails 3
View how_to_concerns.md