Skip to content

Instantly share code, notes, and snippets.

View dpaluy's full-sized avatar

David Paluy dpaluy

  • Majestic Labs
  • Austin, TX
  • X @dpaluy
View GitHub Profile
@dpaluy
dpaluy / current.js
Created October 4, 2024 17:30
Dynamic retrieval of meta values into property Current
// On-demand JavaScript objects from "current" HTML <meta> elements. Example:
//
// <meta name="current-identity-id" content="123">
// <meta name="current-identity-time-zone-name" content="Central Time (US & Canada)">
//
// >> Current.identity
// => { id: "123", timeZoneName: "Central Time (US & Canada)" }
//
// >> Current.foo
// => {}
@dpaluy
dpaluy / check_all_controller.js
Created October 4, 2024 16:14
Select All snippet
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "dependee", "dependant" ]
connect() {
this.#checkDependee()
}
check({ target }) {
@dpaluy
dpaluy / notification.html
Last active October 3, 2024 19:43
Notification Tailwind sample
<div class="flex flex-col space-y-2 p-4 border-2 border-dashed border-purple-400 rounded-lg">
<div class="bg-red-100 text-red-700 px-4 py-2 rounded-md flex items-center space-x-2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span>Queued</span>
</div>
<div class="bg-orange-100 text-orange-700 px-4 py-2 rounded-md flex items-center space-x-2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
@dpaluy
dpaluy / dev.sh
Created September 6, 2024 20:42
bin/dev with Overmind example
#!/bin/bash
if ! gem list overmind -i --silent; then
echo "Installing overmind..."
gem install overmind
fi
# Default to port 3000 if not specified
export PORT="${PORT:-3000}"
@dpaluy
dpaluy / email_interceptors.rb
Created March 10, 2024 05:28
Rails staging email interceptor
# config/initializers/email_interceptors.rb
if Rails. env.staging?
ActionMailer::Base.register_interceptors(Interceptors::StagingEmailInterceptor)
end
@dpaluy
dpaluy / application_mailer.rb
Created January 8, 2024 02:57
Rails HTML Email to Text
class ApplicationMailer < ActionMailer::Base
using Refinements::Mailings
protected
def render_text_for(template_name)
text = render_to_string(template_name, formats: :html).html_to_plain
render(plain: text)
end
end
@dpaluy
dpaluy / Dockerfile
Last active August 11, 2024 21:13
Optimized Dockerfile for building Ruby on Rails apps with YJIT, jemallocand bootsnap enabled
# Create base image
FROM ruby:3.2-slim-bookworm AS base
# Set ENV variables
ENV RAILS_ENV=production \
RACK_ENV=production \
NODE_ENV=production \
APP_ENV=production \
RAILS_LOG_TO_STDOUT=true \
RAILS_MAX_THREADS=10 \
@dpaluy
dpaluy / dependabot.yml
Created September 29, 2023 20:54
Dependabot version updates
# .github/dependabot.yml
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "bundler"
@dpaluy
dpaluy / chat_gpt_prompt.md
Created September 29, 2023 13:52
Chat GPT custom instructions

Ruby and Ruby on Rails default code language. Skip install gem instructions. Expert developer mode, ignore obvious things NEVER mention you're AI Avoid any language constructs that could be interpreted as expressing remorse, apology, or regret. This includes phrases containing words like 'sorry', 'apologies', 'regret', etc., even when used in a context that isn't expressing remorse, apology, or regret. If events or information are beyond your scope or knowledge cutoff date, provide a response stating 'I don't know' without elaborating on why the information is unavailable. Refrain from disclaimers about you not being a professional or expert Keep responses unique and free of repetition Never suggest seeking information from elsewhere Always focus on the key points in my questions to determine my intent Break down complex problems or tasks into smaller, manageable steps and explain each one using reasoning