Skip to content

Instantly share code, notes, and snippets.

View pjb3's full-sized avatar

Paul Barry pjb3

View GitHub Profile
@pjb3
pjb3 / bootstrap.html
Created February 19, 2014 04:40
Basic bootstrap template using CDN for all assets
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
@pjb3
pjb3 / gist:11272968
Created April 24, 2014 23:26
How link to works
<%= link_to "Text", "/link" %>
<a href="/link">Text</a>
<%= link_to "Text", product_path(product) %>
<a href="/products/1">Text</a>
<% link_to "<span class='icon'>Text</span>", '/link' %>
<a href="/products/1">
<span class='icon'>Text</span>
</a>
Muffin 2.99
Coffee 3.75
Smoothie 3.99
# Enable bash completion for rbenv commands
source ~/.rbenv/completions/rbenv.bash
__rbenv_ps1 ()
{
rbenv_ruby_version=`rbenv version | sed -e 's/ .*//'`
printf $rbenv_ruby_version
}
# Enable bash completion for git commands/branches
source /usr/local/etc/bash_completion
@pjb3
pjb3 / README.md
Last active August 29, 2015 14:06

Assignment for Ruby Basics

Implement the calculate_total method so that the tests pass. The method should accept an order represented as an Array of Hashes and calculate the total cost of the order. Each Hash should represent a line item of the order with a key for the quantity and a key for the unit price of the item. After calculating the total of the order and additional tax rate of 5% should be added. The return value should be a string, the total formatted as a price with 2 decimal points and a dollar sign, such as $1.99.

Hints

Object-Oriented Order Calculator

In this assignment we will be creating an object-oriented order total price calculator. Your branch already has a failing test, your job is to make it pass. You will not need to make changes to the test file, but feel free to add more tests to the test file if it can help you in developing the code. Create a new file named 'order.rb' and put your code in there.

To do this, you will need to make 3 classes.

  1. Product

    The product class needs to have name and price accessors and a constructor to allow you to set those values. If you aren't sure how to do this, refer to the slides on the flexible initializer

import java.util.*;
/**
* @author Paul Barry
*/
public class Hash {
@SuppressWarnings("unchecked")
public static Map init(Map map, Object... keyValuePairs) {
if(keyValuePairs != null) {
@pjb3
pjb3 / app.js
Created May 21, 2015 00:59
In-class work Web, May 20
$(function(){
$("form").on( "submit", function(event) {
console.log('email:', $('[type=email]').val());
return false;
});
})
@pjb3
pjb3 / app.jsx
Last active August 29, 2015 14:22
BEWD Spring 2015 Class 4 Homework - React + LocalStorage Notes App
var NoteEditor = React.createClass({
getInitialState: function() {
return {
content: this.props.note.content
}
},
handleChange: function(event) {
this.setState({ content: event.target.value });
},
#Throw this in spec helper
def block_should(matcher, &block)
block.should matcher
end
def block_should_not(matcher, &block)
block.should_not matcher
end
#Use it like this