<div data-controller="toast" data-toast-timeout-value="2500" class="rounded bg-gray-900 px-3 py-2 text-white">
<div class="flex items-start justify-between gap-3">
<div><%= message %></div>
<button type="button" data-action="toast#close">✕</button>
</div>
</div>
# app/channels/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
def subscribed
# Subscribe to a specific room
room = Room.find(params[:room_id])
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["bar", "percent", "status"]
static values = {
current: { type: Number, default: 0 },
// Basic GET request
fetch('https://api.example.com/users')
.then(response => {
console.log('Status:', response.status);
console.log('OK:', response.ok);
return response.json();
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["menu", "overlay", "toggle"]
toggle() {
// Express app with health checks and graceful shutdown
const express = require('express');
const { createServer } = require('http');
const app = express();
const server = createServer(app);
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["container"]
connect() {
import { sha256 } from './crypto.js';
const codeVerifier = crypto.randomUUID() + crypto.randomUUID();
sessionStorage.setItem('pkce_verifier', codeVerifier);
const digest = await sha256(codeVerifier);
<%= turbo_frame_tag 'audit_log', data: { controller: 'lazy-frame', lazy_frame_src_value: audit_log_project_path(@project) } do %>
<div class="py-6 text-gray-500">Scroll to load audit log…</div>
<% end %>
<turbo-stream action="set_title">
<template><%= "Inbox (#{@unread_count})" %></template>
</turbo-stream>
// k6 Load Test Configuration
// Run: k6 run load-test.js --env BASE_URL=https://api.example.com
import http from 'k6/http';
import { check, sleep, group } from 'k6';
import { Rate, Trend, Counter } from 'k6/metrics';
// 1. Create SVG elements
const svgNS = 'http://www.w3.org/2000/svg';
function createSVGElement(type, attributes = {}) {
const element = document.createElementNS(svgNS, type);
Object.entries(attributes).forEach(([key, value]) => {