Skip to content

Instantly share code, notes, and snippets.

View excid3's full-sized avatar
:shipit:
Shipping

Chris Oliver excid3

:shipit:
Shipping
View GitHub Profile
@excid3
excid3 / scaffold_generator.rb
Created February 7, 2024 15:56
Override rails:scaffold generator to add features like Turbo 8 refreshes
class ScaffoldGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
# Run rails:scaffold with the same arguments and options
hook_for :scaffold, in: :rails, default: true, type: :boolean
def turbo_refreshes
# Scaffold generator will have already removed this file on revoke
return if behavior == :revoke
class Request
attr_reader :exception, :response
def initialize(context = {})
@context = context
end
def execute
@response ||= Response.call(execute_request)
self
[color]
ui = true
[user]
name = Chris Oliver
email = excid3@gmail.com
signingkey = 0E881BAF04745832
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
# frozen_string_literal: true
# == AuthenticatesWithTwoFactor
#
# Controller concern to handle two-factor authentication
module AuthenticatesWithTwoFactor
extend ActiveSupport::Concern
def prompt_for_two_factor(user)
@user = user
require 'yaml'
class LocaleGroup
attr_reader :output
def initialize
@output = {}
@output.default_proc = -> (h, k) { h[k] = Hash.new(&h.default_proc) }
end
@excid3
excid3 / index.rb
Created December 13, 2019 22:19
Rubocop Linter Action
# frozen_string_literal: true
require 'json'
require 'net/http'
require 'time'
require 'yaml'
require_relative './report_adapter'
require_relative './github_check_run_service'
require_relative './github_client'
require_relative './install'
class User
def github_student_url
# The School ID GitHub gave you
school_id = "your-school-id"
# The secret key GitHub gave you
secret_key = "secret-key"
# The ID of the student in your database
student_id = id.to_s
@excid3
excid3 / _attachment.html.erb
Last active May 7, 2019 14:39 — forked from aymorgan/_attachment.html.erb
JQuery File Upload, Amazon S3 and Shrine - rendering with a partial
<!-- app/views/attachments/_attachment.html.erb -->
<div class="attachment-image col-xs-6 col-sm-4 col-md-3" id="attachment_<%= @report.slug %><%= attachment.id %>elv1">
<div class="row">
<div class="attached-image-wrapper col-xs-12">
<a class="attached-image" data-lightbox="report-attachment" style="background-image:url('<%= attachment.image_url(:preview) %>');" href="<%= attachment.image_url(:original) %>"></a>
</div>
</div>
<div class="attachment-options-wrapper">
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"]
def attribute(name, value, force_string = false)