Skip to content

Instantly share code, notes, and snippets.

class ApplicationController < ActionController::Base
# While in such a small app, this extraction into a concern seems unnecessary.
# I included this abstraction as an example of DRY and modular code..
include SetRequest
end
@frankolson
frankolson / trix_editor_view_example.erb
Created August 8, 2019 00:48
Trix Editor view example
<%= form_with model: @article do |form| %>
<div class="field">
<%= form.label :title %>
<%= form.text_field :title, placeholder: 'Title' %>
</div>
<div class="field">
<input id="article_content" type="hidden" name="article[content]"
value="<%= form.content %>">
<trix-editor input="article_content"></trix-editor>
@frankolson
frankolson / some_model.rb
Last active October 31, 2019 20:23
Email validation in rails
class SomeModel < ApplicationRecord
validates :email, format: {
with: URI::MailTo::EMAIL_REGEXP,
message: 'requires a valid email format'
}
end
@frankolson
frankolson / rails_helper.rb
Last active January 1, 2020 00:00
Stubbing constants that are used as a side effect of a let! function
# Rails helper config stuff...
# Because `let!' is always run before any `before` calls, you have to manually
# overide the constant in the rails helper
SomeClass.send :remove_const, 'FILE_NAME'
SomeClass.const_set 'FILE_NAME', 'spec/fixtures/files/something/cool.yml'
@frankolson
frankolson / constant-product-market-maker-lw3.tex
Created June 14, 2022 18:59
Constant product market maker expansion for LW3
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
\begin{align*}
x y& = k\\
(x + \Delta x) (y - \Delta y)& = k\\
(x + \Delta x) (y - \Delta y)& = x y

Project Design Document: Golf Range Simulator

  • Created at: mm/dd/yyyy
  • Author: Name

Project Concept

1. Player Control

You control a [PLAYER TYPE] in this [TOP DOWN / SIDE VIEW / ISOMETRIC] game where [USER INPUT TYPE] makes the player [DESCRIPTION OF PLAYER MOVEMENT].