Skip to content

Instantly share code, notes, and snippets.

@benneuman
benneuman / push_data_bags.sh
Created May 23, 2014 15:31
Bash script for pushing data bags. Put in chef-repo dir on your workstation. Make sure you have encryption key at chef-repo/.chef/encrypted_data_bag_secret.
#!/bin/bash
DATA_BAGS=data_bags/users/*
for f in $DATA_BAGS
do
knife data bag from file users $f --secret-file .chef/encrypted_data_bag_secret
done
<html>
<head>
<link rel='stylesheet' href='fullcalendar/fullcalendar.css' />
</head>
<body>
<div id='calendar'>
</div>
<script src='lib/jquery.min.js'></script>
<script src='lib/jquery-ui.custom.min.js'></script>
class BowlingGame
attr_accessor :scorecard
def score
@scorecard.size.times.map { |i| frame_score(@scorecard[i, 3]) }.reduce(:+)
end
def frame_score(frames)
if strike_or_spare?(frames.first)
frames.flatten.first(3).reduce(:+)
else
require 'rspec'
#all gutters -> 0
#scores twenty with one pin knocked down every roll
#spare in frame 1 followed by 3 pins = 16
#strike -> 3-> 4 = 24
#perfect game -> 300
class BowlingGame
attr_reader :scorecard
def initialize
require 'rspec'
# input: integer (0-100)
# output: hash, e.g.
# 5 -> {quarters: 0, dimes: 0, nickels: 1, pennies: 0}
# 12 -> {quarters: 0, dimes: 1, nickels: 0, pennies: 2}
# describe "#make_change" do
# before {
# @change_maker = AmericanChangeMaker.new(ChangeMaker)
require 'rspec'
# input: integer (0-100)
# output: hash, e.g.
# 5 -> {quarters: 0, dimes: 0, nickels: 1, pennies: 0}
# 12 -> {quarters: 0, dimes: 1, nickels: 0, pennies: 2}
describe "#make_change" do
it "1 should return 1 penny" do
expect(make_change(1)).to eq(quarters: 0, dimes: 0, nickels: 0, pennies: 1)
require 'rspec'
def from_roman(roman)
if roman.include? "X"
roman[0] == "X" ? 10 * roman.count("X") + ones(roman) : 9
else
ones(roman)
end
end
require 'rspec'
class Game
attr_reader :player1, :player2
def initialize
@player1 = Player.new('player 1')
@player2 = Player.new('player 2')
@score_view = ScoreView.new(self)
end
require 'rspec'
class Game
attr_reader :player1, :player2
POINTS = [0, 15, 30, 40]
def initialize
@player1 = Player.new('player1')
@player2 = Player.new('player2')
@point = Point.new(@player1, @player2)
@score_view = ScoreView.new(@player1, @player2)
require 'rspec'
def get_score(game)
bonus_tally = []
counter = 0
while counter < game.length
if game[counter] == 10
scores_to_add = [game[counter + 1], game[counter + 2]]
bonus_tally += scores_to_add unless scores_to_add.any?(&:nil?)