Skip to content

Instantly share code, notes, and snippets.

View donalmurtagh's full-sized avatar

Dónal Murtagh donalmurtagh

View GitHub Profile
@donalmurtagh
donalmurtagh / result.java
Created September 13, 2024 13:29
A more realistic version of the code sample on https://result.leakyabstractions.com/
int getServerUptime() throws ConnectionException {
var server = connect();
server.refresh();
return server.getUptime();
}
@donalmurtagh
donalmurtagh / simple-blackjack.md
Last active June 9, 2020 11:55
Simple Blackjack

Introduction

Simple Blackjack is a variant of blackjack. It is a game played by a single player against a dealer. The objective of the game is to draw cards whose total is as close as possible to 21, without exceeding it (AKA "busting").

Rules

The value of a hand of Simple Blackjack is the sum of the card values where

  • The value of an Ace is 11
  • Jacks, Queens, and Kings are worth 10

We start off with the hand represented as a string such as "2H 3H 4H 5H 6H". This is pretty useless so we need to parse it into a data structure we can reason about. Something like

class PokerHand {
  
  PokerHand(String cards) {  
  }
  
 Iterable getCards() { 
@donalmurtagh
donalmurtagh / .bash_profile
Last active August 28, 2024 21:45
configure command prompt
ssPsql() {
docker exec -it bid-event-backend_db_1 su -s /bin/sh - postgres -c "sh -c 'psql postgres'"
}
parseGitBranch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | sed -e 's/^[[:space:]]*//'
}
updateFeatureBranch() {
git pull && git checkout master && git pull && git checkout - && git merge master