clip.mp4
app/views/layouts/application.html.erb
<body class="min-h-screen relative">
<%= render "layouts/flash" %>
</body>
app/views/layouts/_flash.html.erb
app/views/layouts/application.html.erb
<body class="min-h-screen relative">
<%= render "layouts/flash" %>
</body>
app/views/layouts/_flash.html.erb
Stimulus controller (name: 'content-swipe-tab' )
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = ["tabs", 'tabsPane', "swipeArea"]
//[TODO] перенести у static values
static swipeThreshold = 100 // Пороговое значение для определения свайпа (чтобы мелкие движения не учитывались)
startX = null
startY = null
require "active_support/ordered_options"
require 'benchmark/ips'
require 'ostruct'
data = { x: 100, y: 200 }
PointStruct = Struct.new(:x, :y)
point_options = ActiveSupport::OrderedOptions.new
Для интеграции ChatGPT в приложение Rails вам потребуются следующие шаги:
Получите API-ключ GPT, откройте сайт https://openai.com/ и зарегистрируйте аккаунт, елкгда будут инструкции по получению ключа.
Добавьте библиотеку 'httparty' в файл Gemfile вашего приложения и запустите
bundle install
view.html.erb
<div class="horse-wrapper position-absolute">
<%= show_svg('horse.svg') %>
</div>
horse.svg
<svg class="horse" width="50pt" height="50pt" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg">
Header + footer + pagy (start form second page) based on https://github.com/ravi4rails/blogging-app-with-prawn
require 'open-uri'
require 'zip'
class Post < ApplicationRecord
validates :title, presence: true, uniqueness: true
validates :description, presence: true
# Helpers for better embedding and manipulation of videos
# Place this code in app/helpers/videos_helper.rb
# Then from any view you can add:
#
# <%= get_video_iframe('http://the.video.url') %>
#
# Optionally you can add width and height.
#
# <%= get_video_iframe('http://the.video.url', '1600px', '900px') %>
Universal docker method:
docker run -d -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.17.8
curl http://localhost:9200
or in browser
fetch(href, {
headers: {
Accept: "text/vnd.turbo-stream.html",
},
})
.then(r => r.text())
.then(html => Turbo.renderStreamMessage(html))
// optionally reflect the url .then(_ => history.replaceState(history.state, "", href))
module Memoize
def delegate_to_values(*keys)
keys.each do |key|
define_method(key) do
return instance_variable_get(:@bar_cached) if instance_variable_defined?(:@bar_cached)
instance_variable_set(:@bar_cached, rand)
end