Skip to content

Instantly share code, notes, and snippets.

View 123ish's full-sized avatar

123ish LLC 123ish

View GitHub Profile
@123ish
123ish / application.js
Created August 1, 2020 16:27 — forked from kevinhq/application.js
How to migrate from jquery-ujs to rails-ujs - replace
- //= jquery_ujs
+ //= require rails-ujs
@123ish
123ish / example.html.erb
Created August 1, 2020 16:26 — forked from kevinhq/example.html.erb
How to migrate from jquery-ujs to rails-ujs - step 1
<script src="/assets/jquery.js"></script>
<script src="/assets/jquery_ujs.js"></script>
@123ish
123ish / application.amp.erb
Created July 9, 2020 01:49 — forked from kevinhq/application.amp.erb
Create AMP in Rails powered website - application.amp.erb
# app/views/amp/layouts/application.amp.erb
<!DOCTYPE html>
<html amp lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<!-- add/remove ampproject.org scripts as you need it -->
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
@123ish
123ish / show.amp.erb
Created July 9, 2020 01:48 — forked from kevinhq/show.amp.erb
Create AMP in Rails powered website - show.amp.erb
# app/views/amp/samples/show.amp.erb
# write your HTML for AMP page here.
@123ish
123ish / samples_controller.rb
Created July 9, 2020 01:47 — forked from kevinhq/samples_controller.rb
Create AMP in Rails powered website - samples_controller.rb
# app/controllers/samples_controller.rb
Class SamplesController
# other existing methods
def show
# your existing codes
respond_to do |format|
format.html
format.amp { render 'amp/samples/show.amp', layout: 'amp/layouts/application' }
end
@123ish
123ish / mime_types.rb
Created July 6, 2020 20:59 — forked from kevinhq/mime_types.rb
Create AMP in Rails powered website - mime_types.rb
# config/initializers/mime_types.rb
Mime::Type.register 'text/html', :amp
@123ish
123ish / Gemfile
Created July 3, 2020 15:34 — forked from kevinhq/Gemfile
Gemfile with custom environment
group :optimization do
gem 'bullet', '~> 6.1.0'
end
@123ish
123ish / optimization.rb
Created July 3, 2020 15:34 — forked from kevinhq/optimization.rb
Place this on config/environments/optimization.rb
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.rails_logger = true
Bullet.add_footer = true
end
@123ish
123ish / Gemfile
Created July 3, 2020 15:32 — forked from kevinhq/Gemfile
Optimize Rails app with Bullet - Gemfile
gem 'bullet', '~> 6.1.0'
@123ish
123ish / users_controller.rb
Created June 24, 2020 00:35 — forked from kevinhq/users_controller.rb
Two-Factor authentication users controller
# app/controllers/users_controller.rb
class UsersController < ApplicationController
def activate_2fa
qrcode = RQRCode::QRCode.new(current_user.provisioning_uri(nil, issuer: 'your-app-url.com'), :size => 12, :level => :h)
@svg = qrcode.as_svg(offset: 0, color: '000',
shape_rendering: 'crispEdges',
module_size: 4)
respond_to :html
end