Skip to content

Instantly share code, notes, and snippets.

View fieldse's full-sized avatar

Matt fieldse

View GitHub Profile
fieldse /
Created May 13, 2024 15:06
Download webpage as PDF using headless Chrome
fieldse /
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


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


Be sure you really want to do this:

fieldse /
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:
grep -src KEYWORD *.log
# Example output:
# production.20201107.log:12
fieldse /
Created September 29, 2020 15:48
Daily todo file migrator
# Generate a todo file from template
# Today's file
fieldse / Get git file creation
Last active July 10, 2024 11:30
Git tricks: file creation dates for all files in a Git repo directory

Git - print file creation dates


You have a directory of files in a git repository and you want to extract their original creation dates. Git does not track file creation date metadata, but you can get the first time the file was added in a commit.

This one-liner will print the dates and filenames sorted, in column format.

fieldse /
Last active January 31, 2019 16:54
GNOME utility: Install gnome-shell plugins from zip file commandline
# gnome-shell-install
# Utility script to install gnome-shell plugin from zip
## Usage:
# Copy this file to your .local/bin directory and chmod +x [filename]
# From the directory where your downloaded GNOME shell plugin zip is, run
# []
# License:
fieldse / javascript.json
Created December 13, 2018 21:06
VSCode snippet for javascript boxed block comment
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
# calendar_ical.rb
# Todo - date string format
def get_date_format(time_obj)
# Convert standard ruby datetime obj to ISO 8601 format
# time_obj - should be datetime object
# Time format:
# timestring.to_time.iso8601 # Incorrect format! We need 19970610T172345Z
# 1997 06 10 T 17 23 45 Z
fieldse / Firefox multiple profile setup
Last active July 8, 2021 11:22
How to Create a Portable Firefox and Run Multiple Profiles
fieldse / Pytest - Capture print statements in Pytest modules from stdout using capsys parameter
Last active September 14, 2017 04:19
Python pytest + stdout: Capture messages sent to stdout / stderr from your functions with pytest capsys
# Print statements to pytest
# Capture messages sent to stdout / stderr from your functions,
# and test the output with a pytest unit test.
# tl;dr - use the capsys parameter in your test arguments
# extract the messages sent to stdout/stderr with capsys.readouterr()