Skip to content

Instantly share code, notes, and snippets.

View n-at-han-k's full-sized avatar
🚀

Nathan Kidd n-at-han-k

🚀
View GitHub Profile
@john-hamnavoe
john-hamnavoe / rails_7_pagy_ransack.md
Last active May 21, 2025 02:07
How I set up pagy and ransack for simple rails 7 application

Introduction

Adding pagy and ransack in rails so can have search function, paging and sorting on table of date on index controller. We also will use kredis to make it easy to store users last search/sort etc. between pages.

Install

Gemfile:

gem "pagy" gem "ransack"

import { Controller } from "@hotwired/stimulus"
import SignaturePad from 'signature_pad'
export default class extends Controller {
static targets = ["canvas", "input"]
connect() {
this.signaturePad = new SignaturePad(this.canvasTarget)
this.signaturePad.addEventListener("endStroke", this.endStroke)
this.resizeCanvas()
if (this.inputTarget.value) {
@zealot128
zealot128 / simple_form.rb
Created August 13, 2022 14:50
Rails simple_form Tailwind Daisy UI config
# frozen_string_literal: true
#
# Uncomment this and change the path if necessary to include your own
# components.
# See https://github.com/heartcombo/simple_form#custom-components to know
# more about custom components.
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
#
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
@iamtekeste
iamtekeste / credentials.yml
Created May 31, 2022 04:28 — forked from zsyed91/credentials.yml
Using Rails encrypted credentials with database.yml
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: "key generated from <rails secret>"
production:
database_username: username
database_password: password
@alexreardon
alexreardon / drag-and-drop-notes.md
Last active December 16, 2025 12:14
An explanation of the timing of drag and drop events

Drag and drop

This is a collection of knowledge I have built up regarding browser powered drag and drop functionality

Events

dragstart

  • timing: once as drag is starting
  • event.target: draggable Element
@equivalent
equivalent / README.md
Last active July 25, 2025 10:22
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

@tabishiqbal
tabishiqbal / _form.html.erb
Last active October 24, 2025 19:19
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>
@marcus-at-localhost
marcus-at-localhost / bootstrap-5-sass-mixins-cheat-sheet.scss
Created September 6, 2021 06:50 — forked from anschaef/bootstrap-5-sass-mixins-cheat-sheet.scss
All New Bootstrap 5 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 5 Sass Mixins [ Cheat sheet ]
// Updated to Bootstrap v5.1.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/main/scss/mixins
// @see https://github.com/twbs/bootstrap/blob/main/scss/_variables.scss
/* -------------------------------------------------------------------------- */
// Options
// @see https://getbootstrap.com/docs/5.1/customize/options/
@anschaef
anschaef / bootstrap-5-sass-mixins-cheat-sheet.scss
Last active November 28, 2025 16:59
All New Bootstrap 5 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 5 Sass Mixins [ Cheat sheet ]
// Updated to Bootstrap v5.1.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/main/scss/mixins
// @see https://github.com/twbs/bootstrap/blob/main/scss/_variables.scss
/* -------------------------------------------------------------------------- */
// Options
// @see https://getbootstrap.com/docs/5.1/customize/options/
@bjo3rnf
bjo3rnf / confirm-submit.html
Created April 2, 2021 08:39
Stimulus.js driven confirmable submit button
<button type="submit"
class="btn"
data-controller="confirm-submit"
data-confirm-submit-confirmation-label-value="Are you sure?"
data-confirm-submit-warning-class="btn--warning"
data-action="click->confirm-submit#click">
Submit
</button>