Skip to content

Instantly share code, notes, and snippets.

View PurpleBooth's full-sized avatar

Billie Thompson PurpleBooth

View GitHub Profile
@PurpleBooth
PurpleBooth / gfmfmt.fish
Last active March 20, 2020 14:30
Using Pandoc as a (github flavoured) Markdown formatter with wrapping support
#!/usr/bin/env fish
# You can do something similar in fish too
function gfmfmt
for I in $argv
set -lx TEMPORARY_FILE (mktemp -d)"/"(basename "$I")
pandoc --from=gfm --to=gfm --wrap=auto "$I" > "$TEMPORARY_FILE"
mv "$TEMPORARY_FILE" "$I"
end
// Create an object with hollow methods (does not need to implement everything)
const myTestDouble = {
exampleMethod: (): any => {
}
} as RealClass;
// Then to return something
spyOn(myTestDouble, 'exampleMethod').and.returnValue("Stubbed Value");
@PurpleBooth
PurpleBooth / README.md
Created October 26, 2019 09:50
Bowling Kata in rust but more functional

Rules

Create a class with 2 methods:

  • roll(self, pins)
  • score(self)

The rules for scoring are as follows

  • A game is 10 frames
  • Each frame can have up to 2 rolls
  • A spare is when you knock down all pins in a frame
@PurpleBooth
PurpleBooth / README.md
Last active October 24, 2019 21:38
Bowling Kata in rust this time because its been a while.

Rules

Create a class with 2 methods:

  • roll(self, pins)
  • score(self)

The rules for scoring are as follows

  • A game is 10 frames
  • Each frame can have up to 2 rolls
  • A spare is when you knock down all pins in a frame
@PurpleBooth
PurpleBooth / README.md
Last active September 30, 2019 06:05
The Bowling Kata in Nim Lang!

Rules

Create a class with 2 methods:

  • roll(self, pins)
  • score(self)

The rules for scoring are as follows

  • A game is 10 frames
  • Each frame can have up to 2 rolls
  • A spare is when you knock down all pins in a frame

Coin Changer Kata

You've just created a virtual vending machine that will dispense widgets of programming goodness when a user puts money into the machine. The machine should dispense the proper change. You now need the programming logic to determine which coins to dispense.

Write a program that will correctly determine the least number of coins to be given to the user such that the sum of the coins' value would equal the correct amount of change.

Interface

Parameters

KataTennis

About this Kata

This Kata is about implementing a simple tennis game. I came up with it while thinking about Wii tennis, where they have simplified tennis, so each set is one game.

The scoring system is rather simple:

  1. Each player can have either of these points in one game

Mutation Testing

How good are the tests you've been writing all day, and yesterday?

The Command

We're going to use mut.py to run our mutation tests. There are a LOT of options for mutation testing in python, if you find a better one, tell me about it.

Installing mut.py into the environment

@PurpleBooth
PurpleBooth / README.md
Last active June 27, 2020 18:25
Mocking

Mocking Exercises

These are a few exercises to get used to using mocking.

Pairs

Take a list of array elements and group them.

[1, 2, 3, 4, 5]
@PurpleBooth
PurpleBooth / Pipfile
Last active March 20, 2021 12:28
Hacking about with the IMDB Keras data set. Mostly from https://www.tensorflow.org/tutorials/keras/basic_text_classification
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
keras = "*"
tensorflow = "*"