Skip to content

Instantly share code, notes, and snippets.

@heaven
heaven / tailwind-erb
Last active March 28, 2025 10:30
Render .css.erb templates with Tailwind
#!/usr/bin/env sh
INPUT_FILE=""
OUTPUT_FILE=""
TAILWIND_FLAGS=""
print_help() {
echo "Usage: $0 -i <input_file> -o <output_file> [<tailwind_flags>]"
}
@heaven
heaven / tailwind-watch
Last active March 28, 2025 10:31
Watch and render .css.erb templates with Tailwind
#!/usr/bin/env sh
INPUT_FILE=""
OUTPUT_FILE=""
WATCH=false
TAILWIND_FLAGS=""
TAILWIND_SCRIPT="$(dirname "$0")/tailwind-erb"
TAILWIND_PID=0
print_help() {
@heaven
heaven / watch
Last active March 27, 2025 17:56
Tailwind ERB preprocessor and watching tool
#!/usr/bin/env sh
INPUT_FILE=""
OUTPUT_FILE=""
WATCH=false
TAILWIND=false
TAILWIND_FLAGS=""
LAST_MODIFIED=0
print_help() {
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
def errors_report
return nil unless self.source.present?
# self.source — the paperclip attachment
book = Spreadsheet.open(self.source.path)
sheet = book.worksheet(0)
errors = self.import_errors.map { |e| e[:line] }
path = "tmp/#{self.source.original_filename}-errors.xls"