Skip to content

Instantly share code, notes, and snippets.

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].

@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
@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 / 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 / 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>
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 / post_test.rb
Last active October 27, 2018 01:11
Capybara/Trix Editor example tests
# test/system/article/post_test.rb
require 'application_system_test_case'
class Articles::PostTest < ApplicationSystemTestCase
setup do
sign_in_as users(:will)
visit articles_path
end
test 'post a new article' do
@frankolson
frankolson / test_helper.rb
Created October 27, 2018 01:03
Auto-load support files into your test helper
# test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
# Be sure to add this line to include all support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
@frankolson
frankolson / articles.yml
Created October 27, 2018 01:02
Capybara/Trix Editor example fixtures
# test/fixtures/articles.yml
trix_capybara:
title: Testing the Trix Editor with Capybara
content: <div>We are going to learn some cool stuff!</div>
@frankolson
frankolson / capybara_helpers.rb
Created October 27, 2018 01:01
Capybara helpers for the Trix Editor
# test/support/capybara_helpers.rb
def fill_in_trix_editor(id, with:)
find(:xpath, "//trix-editor[@input='#{id}']").click.set(with)
end
def find_trix_editor(id)
find(:xpath, "//*[@id='#{id}']", visible: false)
end