Skip to content

Instantly share code, notes, and snippets.

View phuwanart's full-sized avatar

Phuwanart Larpmark phuwanart

View GitHub Profile
@lucasgeron
lucasgeron / .railsrc
Last active August 13, 2024 14:01
Rails Starter Pack
# place this code in ~/.railsrc
--css=tailwind
--template=~/.rails/template.rb
@n-studio
n-studio / DEPLOY_WITH_KAMAL_ON_DEDICATED_SERVER.md
Last active January 11, 2025 18:52
Deploy a web app on a dedicated server with Kamal

Notes

This guide uses Kamal 1.8.1

Motivation

Kamal was designed with 1 service = 1 droplet/VPS in mind.
But I'm cheap and I want to be able to deploy multiple demo/poc apps apps on my $20/month dedicated server.
What the hell, I'll even host my private container registry on it.

@fzrhrs
fzrhrs / Part 1 of 3: Rails Deployment Ubuntu 24.04 (2024).md
Last active April 4, 2025 05:36
Part 1 of 3: Rails Deployment Ubuntu 24.04 (2024)

Step 1 - Initial Server Setup

Assuming you already ssh-ed into the server as root.

Create a new user

We need to set up a new user account with reduced privileges for day-to-day use.

sudo adduser deploy
@chadwilken
chadwilken / async_reindex_status.rb
Created June 23, 2022 14:56
Searchkick Async Workflow
module Searchkick
class AsyncReindexStatus
include Redis::Objects
def id
'searchkick-async-reindex-status'
end
list :currently_reindexing
end
@tabishiqbal
tabishiqbal / _form.html.erb
Last active January 15, 2025 21:39
Ruby on Rails Tom-Select Example with Stimulus controller
<%= form_with(model: team) do |form| %>
<div>
<%= form.label :name %>
<%= form.text_field :name, class: "input" %>
</div>
<div>
<%= f.select :user_id, {}, {placeholder: "Select user"}, {class: "w-full", data: { controller: "select", select_url_value: users_path }} %>
</div>
@ks2211
ks2211 / Phoenix esbuild with Tailwind and Fontawesome
Last active July 30, 2024 01:50
Phoenix with esbuild, fortawesome, and tailwindcss
Phoenix esbuild with Tailwind+Fontawesome
@KonnorRogers
KonnorRogers / environment.js
Last active July 12, 2024 22:42
ESBuild with Webpacker < 6 in Rails. Bye Babel <3
// DONT FORGET TO `yarn add esbuild-loader` !!!
// config/webpacker/environment.js
const { environment } = require('@rails/webpacker')
const { ESBuildPlugin } = require('esbuild-loader')
const esBuildUse = [
{
loader: require.resolve('esbuild-loader'),
// What you want to compile to, in this case, ES7
@dalezak
dalezak / _form.html.erb
Last active March 11, 2025 05:02
Stimulus.js Toggle Controller to show and hide form elements based on select value
<div class="form-group">
<%= form.label :type, "Type", class: "font-weight-bold" %>
<%= form.select :type, ['TextQuestion', 'UrlQuestion'], { include_blank: true }, { class: "form-control", data: { action: "input->toggle#changed", target: "toggle.select" } } %>
</div>
<div class="form-group">
<%= form.label :name, "Name", class: "font-weight-bold" %>
<%= form.text_field :name, class: "form-control" %>
</div>
<div class="form-group" data-target="toggle.element" data-values="UrlQuestion">
<%= form.label :url, "URL", class: "font-weight-bold" %>
@annikoff
annikoff / custom_generators.md
Last active December 17, 2024 11:38
Custom generators

The main generator

# lib/generators/rails/policy/policy_generator.rb

module Rails
  module Generators
    class PolicyGenerator < NamedBase
      source_root File.expand_path('templates', __dir__)

      def copy_policy_file