Skip to content

Instantly share code, notes, and snippets.

Avatar

Billie Thompson PurpleBooth

View GitHub Profile
@PurpleBooth
PurpleBooth / README.md
Last active Jul 12, 2020
Change your default branch on github without checkout anything out
View README.md

change-github-default-branch.sh

Usage

change-github-default-branch.sh "$GITHUB_TOKEN" PurpleBooth/homebrew-repo

Does not delete the old default branch, or change where pull requests are based from, incase something breaks.

@PurpleBooth
PurpleBooth / README.md
Last active Nov 19, 2020
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
View README.md

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
@PurpleBooth
PurpleBooth / demo.rs
Created Apr 19, 2020
Reading git config from global and the containing repo in rust
View demo.rs
#!/usr/bin/env run-cargo-script
//! This is a regular crate doc comment, but it also contains a partial
//! Cargo manifest. Note the use of a *fenced* code block, and the
//! `cargo` "language".
//!
//! ```cargo
//! [dependencies]
//! git2 = "0.13"
//! ```
View main.rs
use futures::future::join_all;
use futures::StreamExt;
use reqwest::Client;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct ProjectsItem {
hash_id: String,
}
View main.rs
use std::collections::HashMap;
use futures::{stream, StreamExt};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::error::Error;
#[derive(Serialize, Deserialize, Debug)]
struct ProjectsItem {
hash_id: String,
@PurpleBooth
PurpleBooth / 1password
Last active Oct 22, 2020
Use sops to cache the one password vault session token because op is horrible to use
View 1password
#!/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"
@PurpleBooth
PurpleBooth / gfmfmt.fish
Last active Mar 20, 2020
Using Pandoc as a (github flavoured) Markdown formatter with wrapping support
View gfmfmt.fish
#!/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
View test-doubles-in-jasmine.ts
// 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 Oct 26, 2019
Bowling Kata in rust but more functional
View README.md

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 Oct 24, 2019
Bowling Kata in rust this time because its been a while.
View README.md

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
You can’t perform that action at this time.