Skip to content

Instantly share code, notes, and snippets.

View adambray's full-sized avatar

Adam Bray adambray

  • Mechanical Orchard
  • Washington, DC
View GitHub Profile
<br style="clear: both" />
<%= render :partial => 'reservations/reservations_sidebar' if current_user %>
<% unless current_user.equipment_objects.empty? %>
<div id="equipment">
<h3>Your current equipment:</h3>
<%= render :partial => 'users/current_equipment', :object => current_user %>
</div>
<% end %>
<%= yield(:right_sidebar) %>
</div>
<h2 class="catalog"><%= link_to category.name, category_equipment_models_path(category) %></h2>
<ul class="catalog">
<% equipment_models.each do |equipment_model| %>
<li>
<%= (link_to (image_tag equipment_model.photos.first.data.url(:small), :class => 'product_small'), equipment_model.photos.first.data.url, :target => '_blank' ) unless equipment_model.photos.empty? %>
<h3><%= link_to equipment_model.name, equipment_model %></h3>
(<%= equipment_model.available?(cart.start_date..cart.due_date) || "0" %> available from <%= cart.start_date %> to <%= cart.due_date %>)<br />
<%= link_to_remote "[add to cart]", {:url => add_to_cart_path(equipment_model)}, :href => add_to_cart_path(equipment_model) %><br /><br />
</li>
<% end %>
row = []
row.each do |e|
if e.nil?
e = ''
end
row << e
end
@adambray
adambray / ruby_demo.rb
Created May 24, 2013 20:02
Simple Ruby used during intro to Ruby lesson of YEI Bootcamp
def say_hello first_name, last_name
puts "hello, #{first_name}, #{last_name}"
end
say_hello "Adam", "Bray"
name = "Charlie"
name = name.downcase.reverse
if name == "adam"
<!DOCTYPE html>
<html>
<head>
<title>Tickets</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
@adambray
adambray / incident.rb
Created July 26, 2013 23:47
Sample ruby class with dynamic attributes in a hash.
module SN
class Incident
def initialize(attributes = {})
@attributes = attributes
end
def method_missing(method, args = nil)
method_name = method.to_s
if match = method_name.match(/(.*)=/) # writer method
task :prefix_initializer do
prefix_config_file =<<-EOF
Reservations::Application.configure do
config.action_controller.relative_url_root = '/#{application_prefix}'
end
EOF
run "mkdir -p #{shared_path}/config"
put prefix_config_file, "#{shared_path}/config/prefix.rb"
end
@adambray
adambray / prework_self-assesment.md
Created February 19, 2014 16:23
Pre-work Self-Assesment

Web Development Immersive :: Pre-Work Self-Assessment

INSTRUCTIONS

Please spend around 45 minutes to complete this self-assesment - you may record your answers in this form.

We understand that you may not feel 100% comfortable with all of the topics covered in the pre-work, as many of them are new and challenging. We will cover many of these topics in class during the first two weeks. This will give you a chance to continue learning and apply these concepts & tools to your practice.

Q1

@adambray
adambray / gist:9815242
Created March 27, 2014 18:54
Tunr purchases create action
#
def create
song = Song.find(params[:song_id])
if !current_user.songs.include?(song)
# This line here is failing for some reason.
# I expect to get true or false, but I'm getting a
# nilMethodError.
if current_user.debit(song.price)
@purchase = Purchase.create({
@adambray
adambray / life_after_wdi.md
Created September 16, 2014 20:00
Life After WDI June Closure

Life After WDI

Learning Objectives

  • Understand and explain how to be a great developer

Outline

  • Stay hungry... there's always: