Skip to content

Instantly share code, notes, and snippets.

@adambray
adambray / programming_cockatils.md
Created November 13, 2014 20:25
Programming Cocktails

Programming Cocktails

The Best Ideas (All have been served 'in production')

  • Prototype - An Old Fashioned
  • Gem and Tonic - Gin & Tonic + Grenadine
  • Solarized Light - A Tequila Sunrise, name is a play on a terminal theme.
  • Ruby red - red wine with coke (aka Kalimotxo)
  • Bourbon.css - Bourbon on the rocks
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 / 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
<!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 / 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"
<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 %>
<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>
@RobertAKARobin
RobertAKARobin / warmupw01d02.md
Last active August 29, 2015 14:17
Warmup, W01D02

Mission: Impossible!

We, the Impossible Missions Force, have become aware that Doctor Nefarious is planning on using his Nefarious Computer (a standard Macbook) to initiate a nuclear launch sequence that will destroy the entire world.

Our sources have told us that the nuclear launch sequence is run from a shell script, and have also given us a tree showing the contents of the Doctor's computer (the flash drive has been added to show where in the structure it will appear):

NO_NUCLEAR_LAUNCH_SEQUENCES_HERE/
	nopeNotALaunchSequence.sh
TOP_SECRET/
	SERIOUSLY_TOP_SECRET/
@RobertAKARobin
RobertAKARobin / w01d01homework.md
Last active August 29, 2015 14:17
w01d01 Homus Workus

Homework, W01D01


Create a function in your .bash_profile that will set up a working directory for a new GA student!

Things it should do:

  • Create a folder called GeneralAssembly
@adambray
adambray / example_lesson.md
Created February 28, 2015 20:23
Example Lesson Plan - Scaffolding

Domain Modeling and Databases

Learning Objectives

  • Describe the basic parts of an ERD
  • Construct ERDs to model the nouns and relationships in a domain
  • Explain what a database is and why you would use one as opposed to other persistent storage mechanisms
  • Explain the difference between a database management system (R/DBMS) and a database, and name the major DBMSes