Skip to content

Instantly share code, notes, and snippets.


Paul Barry pjb3

View GitHub Profile
pjb3 / app.jsx
Last active Aug 29, 2015
BEWD Spring 2015 Class 4 Homework - React + LocalStorage Notes App
View app.jsx
var NoteEditor = React.createClass({
getInitialState: function() {
return {
content: this.props.note.content
handleChange: function(event) {
this.setState({ content: });
pjb3 / app.js
Created May 21, 2015
In-class work Web, May 20
View app.js
$("form").on( "submit", function(event) {
console.log('email:', $('[type=email]').val());
return false;
pjb3 / terminator.sql
Created Mar 25, 2015
Kill all queries that have been running for more than a minute in a Postgres datavase
View terminator.sql
select pg_terminate_backend(pid)
from (
FROM pg_stat_activity
WHERE query <> '<insufficient privilege>'
AND state <> 'idle'
AND pid <> pg_backend_pid()
AND query_start < now() - interval '1 minute'
ORDER BY query_start DESC) t;

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


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.


# 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
View products.csv
Muffin 2.99
Coffee 3.75
Smoothie 3.99
pjb3 / gist:11272968
Created Apr 24, 2014
How link to works
View gist:11272968
<%= 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>
pjb3 /
Created Apr 2, 2014
How to fake your location in a browser
@navigator.geolocation.watchPosition = (callback) ->
latitude: 39.286031201326416,
longitude: -76.61204230156727
, 5000)
pjb3 / .irbrc
Last active Feb 19, 2016
Basic Ruby IRB config
View .irbrc
require 'irb/completion'
# History
#require 'irb/ext/save-history' #wirble does history
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:AUTO_INDENT] = true
# use HIRB if available
You can’t perform that action at this time.