Related to Rails issue report: rails/rails#38881
original template https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb
def x | |
user_id = Rails.application.credentials.dig(:htmlcsstoimage, :user_id) #this will return my Htmlcsstoimage user_id | |
key = Rails.application.credentials.dig(:htmlcsstoimage, :key) #this will return my Htmlcsstoimage key | |
auth = { username: user_id, password: key } | |
html = '<body>' | |
html += '<h1>Rose Tattoo</h1>' | |
html += '<h2>Dropkick Murphys</h2>' |
Related to Rails issue report: rails/rails#38881
original template https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb
# config/initializers/devise.rb | |
class CustomFailureApp < Devise::FailureApp | |
def http_auth_body | |
case request_format | |
when :js, 'js' | |
'alert(" not authorized !");' | |
when :json, 'json' | |
{ error: i18n_message } | |
else | |
i18n_message |
benchmark for article Ruby Memoization: ||= vs. Defined? Syntax
If you want to have color strings for Unix Ruby string and you don't want to use gem like colorize
This is copy-paste version of Inputs gem
This is helpfull if you just want to paste the Inputs gem functionality to a Ruby script when
library install (gem install inputs
or bunde install
) is not an option.
Just Copy-Paste the code bellow to your script and you'll have all the features of Inputs gem
# config/initializers/materialize_form.rb | |
# | |
# So that you have Materialize CSS validation message https://materializecss.com/text-inputs.html such as | |
# | |
# <div class="input-field"> | |
# <label for="company_title" class="active">Title</label> | |
# <input type="text" value="" name="company[title]" id="company_title" class="invalid"> | |
# <span data-error="can't be blank" class="helper-text"></span> | |
# </div> |
# this Ruby method definiton will get defined successfuly | |
def | |
'magic !' | |
end | |
# but this Ruby method definiton will Fail with syntax error: syntax error, unexpected keyword_end, expecting end-of-input | |
def | |
'magic !' | |
end |
# /etc/motion/motion.conf on my Raspberian | |
# Rename this distribution example file to motion.conf | |
# | |
# This config file was generated by motion 4.0 | |
############################################################ | |
# Daemon | |
############################################################ |
require 'active_model' | |
class RequestModel | |
include ActiveModel::Validations | |
attr_reader :params, :ero | |
def initialize(params, ero) | |
@params = params | |
@ero = ero |