Skip to content

Instantly share code, notes, and snippets.

View rhysforyou's full-sized avatar

Rhys Powell rhysforyou

View GitHub Profile
if ($('#cart tr').length == 1) { $('#cart').show('blind', 1000); }
$('#cart').html("<%=j render @cart %>");
$('#current_item').css({'background-color':'#88ff88'}).
animate({'background-color':'#114411'}, 1000);
Feature: Adding games
In order to have games to track, I must have some way of adding new games.
This process should be as quick and painless as possible to minimise the
friction of using the app.
Scenario: Adding a game
Given I am on the new game page
When I fill out the new game form with valid attributes
Then I should be informed that the game was created
require 'spec_helper'
describe Game do
subject { FactoryGirl.build :game }
it "requires a title" do
subject.title = ""
subject.save.should be_false
subject.errors.should include("can't be blank")
end
Given /^I am on the new note page$/ do
visit new_note_path
end
When /^I fill out the new note form$/ do
@note = Factory.build :note
fill_in "note_title", with: @note.title
fill_in "note_content", with: @note.content
end
describe SubjectsController do
context "POST create" do
it "creates a new record and shows it given valid attributes" do
subject_attrs = Factory.attributes_for(:subject)
post :create, subject: subject_attrs
# The following line raises an exception:
# Failure/Error: response.should redirect_to(:action => :show)
# Expected response to be a redirect to <http://test.host/assets?action=show&controller=subjects> but was a redirect to <http://test.host/subjects/1>
response.should redirect_to(action: :show)
end
// Break this up into km, m, and cm
kilometres = sum / 100000;
metres = (sum / 100) % 1000;
centimetres = sum % 100;
// Output the final value as a formatted string
printf("\n%d %d %d\n", kilometres, metres, centimetres);
#include <iostream>
using namespace std;
int main()
{
int day = -1;
char mon1, mon2, mon3; // The three letters for the name of the month
int year = -1;
cout << "Input a date formatted like DD-MMM-YYYY" << endl;
SET sorted to true
DO
SET sorted to true
IF value1 > value2
SET temp to value1
SET value1 to value2
SET value2 to temp
SET sorted to false
END
#include <iostream>
using namespace std;
int main()
{
int num1, num2, num3 , num4, num5;
bool sorted = true;
do {
if num1 > num2 {
File.open("IDCJAC0009_068131_1800_Data.csv", 'r') do |f|
while line = f.gets
values = line.split(',')
# values[2] is the year and values[5] is the amount of rainfall
if values[2] == "2011" && values[5] != '' && values[5] != '0.0'
puts values[5]
end
end
end