- Add tom-select to Rails app
yarn add tom-select
- Add to 'app/javascript/stylesheets/application.scss'
@import "tom-select/dist/css/tom-select.bootstrap5";
1) Create: | |
========== | |
app/javascript/utilities/preview_avatar.js | |
------------------------------------------ | |
document.addEventListener("turbolinks:load", function(event) { | |
function readURL(input) { | |
if (input.files && input.files[0]) { | |
var reader = new FileReader() | |
reader.onload = function (e) { | |
document.getElementById(input.id + "_medium").setAttribute('src', e.target.result) |
html section (erb) | |
================== | |
<div class="wrapper"> | |
<h3 class='text-center mt-3 mb-4'><%= t('.edit_profile') %></h3> | |
<input type="radio" name="slider" checked id="home"> | |
<input type="radio" name="slider" id="code"> | |
<input type="radio" name="slider" id="about"> | |
<nav class='mx-auto mb-4'> | |
<!-- Icon and name Tab 1 ('Main') --> |
1) Local terminal | |
================= | |
yarn add @fortawesome/fontawesome-free | |
2) javascript/packs/application.js | |
================================== | |
import "@fortawesome/fontawesome-free/css/all" |
Quick guide to add gem invisible_captcha (https://github.com/markets/invisible_captcha) to your devise registrations. | |
------- for model User --------- | |
1) gemfile: | |
============ | |
gem 'invisible_captcha' | |
2) console: | |
=========== | |
bundle |
require 'aws-sdk-s3' | |
# Create s3 instance | |
==================== | |
s3 = Aws::S3::Resource.new(access_key_id: Rails.application.credentials.dig(:aws, :access_key_id), | |
secret_access_key: Rails.application.credentials.dig(:aws, :secret_access_key), | |
region: 'us-east-1' ) | |
# Create client instance | |
======================== | |
client = Aws::S3::Client.new(access_key_id: Rails.application.credentials.dig(:aws, :access_key_id), |
yarn add tom-select
@import "tom-select/dist/css/tom-select.bootstrap5";
https://www.robinwieruch.de/react-hooks-fetch-data | |
useEffect(() => { | |
let didCancel = false; | |
async function fetchMyAPI() { | |
let url = 'http://something/' + productId; | |
let config = {}; | |
const response = await myFetch(url); | |
if (!didCancel) { // Ignore if we started fetching something else |
1) yarn add bootstrap | |
2) yarn add @popperjs/core | |
3.1) in folder 'app/javascript/' create new folder 'stylesheets': | |
mkdir app/javascript/stylesheets/ | |
3.2) in new folder 'stylesheets' create file 'application.scss' | |
cd app/javascript/stylesheets/ | |
touch application.scss |
// Timer 5 sec -> count = 5000 | |
// stop timer -> running = false | |
var count = 5000, | |
running = true, | |
secondsNode = document.getElementById("seconds"), | |
millisecondsNode = document.getElementById("milliseconds"), | |
mOld, | |
mNew; |