This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails new sample-02_bun_tw_phlex_htmx -j bun -c tailwind -d sqlite3 --skip-hotwire --skip-jbuilder --skip-bootsnap | |
bin-/bundle add rails-htmx | |
bin/bundle add phlex-rails | |
bin/rails generate phlex:install | |
bin/bundle add tailwindcss-rails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "faker" | |
class ArticleComponent < ApplicationComponent | |
def template | |
article(class: "mb-2 bg-blue-600 rounded border-solid border-2 border-black item-article") { | |
h3(class: "text-left text-slate-200 pl-2 font-semibold") { | |
i { Faker::Lorem.sentence } | |
} | |
p(class: "bg-slate-200 p-4") { Faker::Lorem.paragraph } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Articles::IndexView < ApplicationView | |
HEAD_STYLE = "p-2 font-mono font-bold font-lg font-bold" | |
BUTTON_STYLE = "font-mono rounded border-2 border-black bg-indigo-200 p-1 text-sm transition-colors focus-ring-2 focus:ring-indigo-800 hover:bg-indigo-100" | |
def template | |
div(class: "h-16 flex items-center justify-between") { | |
h1(class: HEAD_STYLE) { "Articles index" } | |
button("hx-post": articles_path, "hx-target": "#article-list", "hx-swap": "afterbegin", | |
class: BUTTON_STYLE) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticlesController < ApplicationController | |
layout -> { ApplicationLayout } | |
def index | |
render Articles::IndexView.new | |
end | |
def create | |
render ArticleComponent.new, layout: false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationLayout < ApplicationView | |
include Phlex::Rails::Layout | |
def template(&block) | |
doctype | |
html do | |
head do | |
title { "Rails demo" } | |
meta name: "viewport", content: "width=device-width,initial-scale=1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Dump the data only sql to file | |
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql | |
2. scp to local | |
3. Remove the SET statements at the top | |
such as: | |
SET statement_timeout = 0; | |
SET client_encoding = 'SQL_ASCII'; | |
4. Remove the setval sequence queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gtk.reset | |
class TetrisGame | |
# This is just to get GTK to not complain in the console for now. | |
def serialize ; { args: '' } ; end | |
def inspect ; serialize.to_s ; end | |
def to_s ; serialize.to_s ; end | |
def render_cube_pixelpos x, y, r, g, b, a=255 | |
@args.outputs.solids << [ x, y, @boxsize, @boxsize, r, g, b, a ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gtk.reset | |
class TetrisGame | |
def initialize args | |
@args = args | |
@next_piece = nil | |
@next_move = 30 | |
@score = 0 | |
@gameover = false | |
@grid_w = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EditorConfig helps developers define and maintain consistent | |
# coding styles between different editors and IDEs | |
# editorconfig.org | |
root = true | |
[*] | |
end_of_line = lf | |
charset = utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'rubygems' | |
require 'aws-sdk' | |
module S3 | |
# Upload directory recursively to S3 | |
class DirectoryUpload | |
attr_reader :folder_path, :bucket, :include_folder | |
attr_accessor :files |
NewerOlder