Skip to content

Instantly share code, notes, and snippets.

View justalever's full-sized avatar
🦄
building all the things

Andy Leverenz justalever

🦄
building all the things
View GitHub Profile
@justalever
justalever / application.tailwind.css
Last active July 29, 2024 11:13
Tailwind button fix
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "./components/buttons.css";
@import "tailwindcss/utilities";
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "./components/buttons.css";
@import "./components/forms.css";
@import "tailwindcss/utilities";
<% flash.each do |type, message| %>
<% if type == "alert" %>
<div class="bg-red-500">
<div class="container px-2 mx-auto py-4 text-white text-center font-medium font-sans">
<%= message %>
</div>
</div>
<% end %>
<% if type == "notice" %>
<div class="bg-green-500">
@justalever
justalever / routes.rb
Created June 7, 2021 18:30
Ruby on Rails routing
# This is for reference via the blog post/view at https://web-crunch.com/posts/ruby-on-rails-routing
require 'sidekiq/web'
Rails.application.routes.draw do
authenticate :user, lambda { |u| u.admin? } do # ensures authenticated users who are admins can only access anything within this block
mount Sidekiq::Web => '/sidekiq' # built into the sidekiq gem
end
devise_for :users # built into the Devise gem
@justalever
justalever / validate_array_datatype.rb
Created January 3, 2020 03:08
Validate an array data type in Ruby on Rails using a custom validator - PostGresQL allows arrays as a DB type.
# Define the validator
# app/validators/array_validator.rb
class ArrayValidator < ActiveModel::EachValidator
def validate_each(record, attribute, values)
Array(values).each do |value|
options.each do |key, args|
validator_options = { attributes: attribute }
validator_options.merge!(args) if args.is_a?(Hash)
@justalever
justalever / Gemfile
Created June 23, 2019 21:11
version 5.2.3 Rails + simple_form gem update
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', "5.2.3"
<%= simple_form_for @tweet do |f| %>
<%= f.error_notification %>
<div class="field">
<div class="control">
<%= f.input :tweets, label: "Tweeet about it", input_html: { class: "textarea"}, wrapper: false, label_html: {class: "label"}, placeholder: "Compose a new tweeet...", autofocus: true %>
</div>
</div>
<%= f.button :submit, class: "button is-info" %>
<% end %>
@justalever
justalever / TweetsController.rb
Created February 26, 2018 15:42
Fixes naming conventions
class TweetsController < ApplicationController
before_action :set_tweet, only: [:show, :edit, :update, :destroy]
# GET /tweets
# GET /tweets.json
def index
@tweets = Tweet.all.order("created_at DESC")
@tweet = Tweet.new
end
@justalever
justalever / static-Gulpfile.js
Created April 7, 2017 04:37
A Gulp config for serving static sites.
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
sourcemaps = require('gulp-sourcemaps'),
@justalever
justalever / Gulpfile.js [Final]
Created March 23, 2017 18:06
BrowserSync Snippet
// Base Gulp File
var gulp = require('gulp'),
watch = require('gulp-watch'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
cssBase64 = require('gulp-css-base64'),
path = require('path'),
notify = require('gulp-notify'),
inlinesource = require('gulp-inline-source'),
browserSync = require('browser-sync'),