Skip to content

Instantly share code, notes, and snippets.

View phuwanart's full-sized avatar

Phuwanart Larpmark phuwanart

View GitHub Profile
@phuwanart
phuwanart / README.md
Created October 5, 2022 04:57 — forked from leastbad/README.md
Choices.js Stimulus wrapper preview

Choices.js Stimulus wrapper

https://joshuajohnson.co.uk/Choices/

Soon, this will be published as an NPM package, but there's an absence of documentation right now. It supports almost all functions from the original library; soon it will support 100% of them.

This wrapper adds Ajax pre-fetch search. Happens if controller has a data-search-path attribute.

Stimulus controller targets use new v2 syntax. Controller attaches a reference to itself on the element so that you can access the internal state from external scripts.

@phuwanart
phuwanart / select_controller.js
Created February 24, 2023 05:44 — forked from tabishiqbal/_form.html.erb
Tom-Select Example with Stimulus
import { Controller } from "stimulus"
import TomSelect from "tom-select"
export default class extends Controller {
static values = { url: String }
connect() {
this.initTomSelect()
}
@phuwanart
phuwanart / README.md
Created February 24, 2023 05:51 — forked from bigglesrocks/README.md
Rails Scoped Invitation System

#Scoped Invitation System for User Groups with Rails#

Starting out with the following models and associations:

####User

  • has_many :memberships
  • has_many :organizations through :memberships

####Organization (User Group)

  • has_many :memberships
@phuwanart
phuwanart / README.md
Created February 24, 2023 05:52 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@phuwanart
phuwanart / rails-5-6-ubuntu-mina-puma-nginx.md
Created November 26, 2023 18:01 — forked from wafiq/rails-5-6-ubuntu-mina-puma-nginx.md
How to deploy Rails 5/6 in Ubuntu VM using Mina deployment with Puma webserver and Nginx

Rails 5 and 6 Deployment with Ubuntu, Mina, Puma and Nginx

Based on this tutorial but simplified and inlined. Particularly removed any Rails and 3rd party services part, assumed you just need deployment to any Ubuntu machine.

Prerequisite

  1. A functional Rails app
  2. Hosted Git repository (Github, Bitbucket, Gitlab)
  3. Cloud hosting account (Digital Ocean, Vultr, Linode, Lightsail)
  4. Local SSH account
@phuwanart
phuwanart / DEPLOY_WITH_KAMAL_ON_DEDICATED_SERVER.md
Created January 23, 2024 06:25 — forked from n-studio/DEPLOY_WITH_KAMAL_ON_DEDICATED_SERVER.md
Deploy a web app on a dedicated server with Kamal

Warning

This gist is still a draft. At the moment it is not functional: see basecamp/kamal#257

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.