Skip to content

Instantly share code, notes, and snippets.

View PurpleBooth's full-sized avatar

Billie Thompson PurpleBooth

View GitHub Profile
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 22, 2024 11:45
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@PurpleBooth
PurpleBooth / 1password
Last active April 17, 2024 04:01
Use sops to cache the one password vault session token because op is horrible to use
#!/usr/bin/env bash
set -euo pipefail
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/Library/Caches}/wrapper-1password"
CACHE_FILE="$CACHE_DIR/session-token.yaml"
OP_LOCATION="$(command -v op)"
mkdir -p "$CACHE_DIR"

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a

Docker Container Name

A one paragraph description about the container.

Getting Started

These instructions will cover usage information and for the docker container

Prerequisities

@PurpleBooth
PurpleBooth / write-me-a-commit-message.py
Last active March 25, 2024 02:20
I cba with writing my own commit messages anymore
#!/usr/bin/env python
import json
import logging
import subprocess
import sys
import textwrap
from typing import Literal, Sequence, TypedDict, Union
from urllib.error import HTTPError
from urllib.request import Request, urlopen
@PurpleBooth
PurpleBooth / Dockerfile
Last active March 21, 2024 09:33
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@PurpleBooth
PurpleBooth / ExampleController.php
Last active March 3, 2024 14:22
Set the symfony _format property from the Accepts header based on what the serializer can support
<?php
declare(strict_types=1);
namespace PurpleBooth\Bundle\ExampleBundle\Controller\Api;
use PurpleBooth\Bundle\ExampleBundle\Entity\Example;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
@PurpleBooth
PurpleBooth / copy-labels.sh
Created February 15, 2023 10:37
Copy labels between repos on github
#!/usr/bin/env bash
set -xeuo pipefail
# Set the source repository
SOURCE_REPO=org-name/source-repo
# Set the target repository
TARGET_REPO=org-name/dest-repo
@PurpleBooth
PurpleBooth / README.md
Last active September 8, 2023 20:52
A github workflow pipeline for rust that does test, build and deploy windows, linux and mac, creates releases, and does SemVer Versioning, and releases to a homebrew tap

Features

  • Automatically bump SemVer
  • Update a personal homebrew tap
  • Keep that pesky version in the Cargo.toml up to date
  • (From dependabot) Get new versions out as soon as possible

Assumptions

  • You don't want a changelog

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