This gist will collects all issues we solved with Rails 5.2 and Webpacker
# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test| 为hass接入小米空气净化器2 |
This gist will collects all issues we solved with Rails 5.2 and Webpacker
# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test| sudo su | |
| //Setup Hostname | |
| hostnamectl set-hostname subdomain.domain.tld | |
| ## Basic | |
| sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get autoremove -y && sudo apt-get install software-properties-common | |
| //Setup SWAP | |
| sudo fallocate -l 1G /swapfile; | |
| ls -lh /swapfile; |
| // Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub | |
| export default async function getTitleFromUrl (url: string) { | |
| const controller = new AbortController(); | |
| const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds | |
| const title = await fetch(url, { signal: controller.signal }) | |
| .then((res) => { | |
| clearTimeout(timeoutId); | |
| return res.text(); | |
| }) |
| # This is a thin wrapper of the Simple Form builder. It delegates rendering the resulting form fields to Simple Form | |
| # but typically amends the Tailwind classes of the various elements in the field layout. It tightly integrates with the | |
| # unstyled wrapper (aka `:plain`) Simple Form configuration (see `simple_form.rb`). The methods support the same syntax | |
| # as the original Simple Form methods but enhance it to support replacing defaylt Tailwind claseses. | |
| class Builders::TailwindFormBuilder < SimpleForm::FormBuilder | |
| # This is the basic method for rendering `<input>` tags and their variants. | |
| def input(attribute_name, options = {}, &block) | |
| # The default Tailwind classes for the various parts of the Simple Form wrapper layout. | |
| input_class = "block w-full sm:text-sm ... #{'text-gray-500 bg-gray-50' if options.dig(:input_html, :disabled)}" |
| node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" | |
| # frozen_string_literal: true | |
| require 'bundler/inline' | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'dotenv' | |
| gem 'ruby-openai' | |
| end |