Skip to content

Instantly share code, notes, and snippets.

View hturnbull93's full-sized avatar

Harry Turnbull hturnbull93

View GitHub Profile
@hturnbull93
hturnbull93 / index.js
Created May 11, 2020 17:47
Indecisive React App
import React from 'react';
import ReactDOM from 'react-dom';
class Header extends React.Component {
constructor(props) {
super(props);
this.state = {favouritecolour: "red"};
}
@hturnbull93
hturnbull93 / multi-task-blog-3.js
Created May 1, 2020 16:57
For "Convincing JavaScript to Multi Task" blog
var shops = {
items: ["ham", "eggs", "spam"]
};
var home = {
fridge: null
};
var delivery = {
fridge: {
@hturnbull93
hturnbull93 / multi-task-blog-2.js
Last active May 1, 2020 11:48
For "Convincing JavaScript to Multi Task" blog
function groceryShopping() {
goToShops()
let shoppingBags = [...shops.items]
goHome()
setTimeout(() => {
home.fridge.contents = [...shoppingBags]
console.log("Shopping is in the fridge")
}, 0);
}
@hturnbull93
hturnbull93 / multi-task-blog.js
Last active May 1, 2020 11:48
For "Convincing JavaScript to Multi Task" blog
// Some variables to handle
var shops = {
items: ["ham", "eggs", "spam"]
}
var home = {
fridge: null
}
@hturnbull93
hturnbull93 / multi-task-blog.md
Last active May 1, 2020 11:19
For "Convincing JavaScript to Multi Task" blog
  • Grocery Shopping
    1. Go to the shops
    2. Get shopping
    3. Return home
    4. Put shopping in fridge
  • Receive Fridge Delivery
    1. Wait for Curry's delivery
    2. Receive fridge from delivery
    3. Install fridge
@hturnbull93
hturnbull93 / capybara_sinatra_false_positives_3.rb
Created April 24, 2020 20:14
For "Avoiding False Positives with Capybara and Sinatra" blog
require 'sinatra/base'
class Echo < Sinatra::Base
get '/' do
erb :index
end
post '/echo' do
param['echo'] # I hope this does not contain an error!
end
@hturnbull93
hturnbull93 / capybara_sinatra_false_positives_2.rb
Created April 24, 2020 20:02
For "Avoiding False Positives with Capybara and Sinatra" blog
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Echo</title>
</head>
<body>
<h1>Echo Generator</h1>
@hturnbull93
hturnbull93 / capybara_sinatra_false_positives_1.rb
Created April 24, 2020 20:00
For "Avoiding False Positives with Capybara and Sinatra" blog
feature 'Echo' do
scenario 'Entering Hello echos Hello' do
visit '/'
expect(page).to have_content 'Echo Generator'
fill_in('echo', with: "Hello")
click_on 'Shout'
expect(page).to have_content 'Hello'
end
end
@hturnbull93
hturnbull93 / journey_oop_blog_4.rb
Last active March 29, 2020 19:56
For "A journey with OOP" blog.
Rspec.describe Journey do
let(:method_of_transport_class_double) { double(:method_of_transport, new: method_of_transport_instance_double) }
let(:method_of_transport_instance_double) { double(:method_of_transport) }
let(:isolated_journey) { described_class.new("the shops", method_of_transport_class_double) }
it '#start calls start on the object contained in @method_of_transport' do
expect(method_of_transport_instance_double).to receive(:start)
isolated_journey.start
@hturnbull93
hturnbull93 / journey_oop_blog_3.rb
Last active March 29, 2020 19:34
For "A journey with OOP" blog.
class Journey
def initialize(destination, mode_of_transport = Walk)
@destination = destination
@mode_of_transport = mode_of_transport.new
end
def start
@mode_of_transport.start(@destination)
end