Skip to content

Instantly share code, notes, and snippets.

View fieldse's full-sized avatar

Matt fieldse

View GitHub Profile
@fieldse
fieldse / grep_match_count.sh
Created November 15, 2020 10:13
Grep/zgrep: count matches across multiple files
# Count occurences of KEYWORD across all files named [something].log
# Flag: -src
# Credit:
# https://superuser.com/questions/205591/show-the-matching-count-of-all-files-that-contain-a-word
grep -src KEYWORD *.log
# Example output:
# production.20201107.log:12
@fieldse
fieldse / git-reset-hard-to-master.md
Last active October 18, 2023 09:32
How to perform a hard reset of a git branch to master

Git - Hard reset branch to current master

Scenario

  • You have Git branches main and branch staging.
  • You need to reset staging exactly to the state of branch main.

Warnings

Be sure you really want to do this:

@fieldse
fieldse / download-headless-chrome.md
Created May 13, 2024 15:06
Download webpage as PDF using headless Chrome
@fieldse
fieldse / Get largest element.md
Last active March 6, 2025 08:10
Get the largest element from an integer array in Typescript using `reduce()`

Get largest element from integer array in Typescript

// Return highest element from array
const getMax = (arr: number[]): number =>
  arr.reduce((max, current) => {
    return current > max ? current : max;
  }, arr[0]);
@fieldse
fieldse / docker-compose-show-hashes.md
Created March 30, 2025 08:58
Docker compose: Get docker to show intermediate build layer hashes

Docker compose: Get docker to show intermediate build layer hashes

By default, Docker compose hides the intermediate build layer hashes. This makes debugging difficult.

To get display of hashes after each build step, use the following:

DOCKER_BUILDKIT=0 docker-compose build ....