Youtube video in popup modal

It is simple iframe similar to this solution just with stop video after modal is closed with Esc

<div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="videoModal" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-body">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <iframe width="100%" height="350" src=""></iframe>

 <a href="#" class="btn btn-default" data-toggle="modal" data-target="#videoModal" data-theVideo="" >VIDEO</a>

$('[data-theVideo]').click(function () {
  var theModal = $(this).data( "target" ),
  videoSRC = $(this).attr( "data-theVideo" ), 
  videoSRCauto = videoSRC+"?autoplay=1" ;
  $(theModal+' iframe').attr('src', videoSRCauto);
  $(theModal+' button.close').click(function () {
      $(theModal+' iframe').attr('src', videoSRC);

$('#videoModal').on('', function() {
  $(this).find('iframe').attr('src', null);

Google pdf preview

If you want to preview pdf or image file, you can use Google

$('#viewerBox').attr('src','<%= %>' );

or you can use directly pdf.js

yt gem access youtube api. Creators Private or non existing video url raise exceptions so you need to rescue Yt::Errors::NoItems, Yt::Errors::RequestError. Video could be public but not accessible (because of deactived account).

Gmail API

Someone can break to your account simple by adding his email as recovery email. Than he can easily change password.

Gmail shortcuts

  • ? to open keyboard shortcut help
  • Ctrl+Enter to send email
  • j and k to older and newer conversation
  • o to open conversation, u to back to threadlist
  • g+a go to all mail, g+t to sent emails, g+i to inbox
  • c to compose
  • / to search


Register on and you can use in in javascript <div class="g-recaptcha" data-sitekey="6LdrgFQUAAAAALvyQvT3fpoagmnb-ik9f73Y0Zaz"></div> but on rails and devise follow and gem

Example is

# Gemfile
# captcha on contact form
gem 'recaptcha'

# config/locales/en.yml
      verification_failed: reCAPTCHA verification failed, please try again.

# app/form_objects/contact_form.rb
require 'recaptcha/verify'

class ContactForm
  include ActiveModel::Model
  include Recaptcha::Verify

  attr_accessor :email, :text, :g_recaptcha_response, :current_user, :remote_ip
  validates_format_of :email, with: Devise.email_regexp
  validates :text, :email, presence: true

  def save
    verify_recaptcha model: self, response: g_recaptcha_response
    return false if errors.present?
    return false unless valid?


  def request remote_ip: remote_ip

  def env

  def _send_notification
    Notify.message("contact_form #{email} @ #{}", email, text, remote_ip, current_user)

# app/controllers/pages_controller.rb
  def contact
    @contact_form =
      email: current_user&.email

  def submit_contact
    @contact_form =
      email: current_user&.email || params[:contact_form][:email],
      text: params[:contact_form][:text],
      g_recaptcha_response: params['g-recaptcha-response'],
      current_user: current_user,
      remote_ip: request.remote_ip,
    if[:notice] = t('contact_thanks')
    else[:alert] = @contact_form.errors.full_messages.join(', ')
    render :contact

# app/assets/javascripts/
window.enableRecaptchaButtons = (e) ->
  console.log 'enableRecaptchaButtons'
  $('[data-recaptcha-button]').prop('disabled', false)

# config/initializers/recaptcha.rb
Recaptcha.configure do |config|
  config.site_key = Rails.application.secrets.google_recaptcha_site_key
  config.secret_key = Rails.application.secrets.google_recaptcha_secret_key

# config/secrets.yml
  # Google recaptcha
  google_recaptcha_site_key: <%= ENV['GOOGLE_RECAPTCHA_SITE_KEY'] %>
  google_recaptcha_secret_key: <%= ENV['GOOGLE_RECAPTCHA_SECRET_KEY'] %>

Use Checkbox v2 (Invisible is similar, just you need to trigger using js and use callback to receive results). V3 is for scoring.

It is not possible to edit configuration using api so use selenium script to update redirect URIs. You can use 50 domain with one key.