Skip to content

Instantly share code, notes, and snippets.

View davidmurdoch's full-sized avatar
💭
Building

David Murdoch davidmurdoch

💭
Building
View GitHub Profile
@davidmurdoch
davidmurdoch / getLastCommitDatetimeUtc.ts
Last active December 15, 2023 15:17
A Node.js function to get the latest commit's authorship timestamp in UTC (millisecond precision)
/**
* Retrieves the datetime of the last commit in UTC for the current Git branch.
*
* The author timestamp is used for its consistency across different
* repositories and its inclusion in the Git commit hash calculation. This makes
* it a stable choice for reproducible builds.
*
* @returns Millisecond precision timestamp in UTC of the last commit on the
* current branch. If the branch is detached or has no commits, it will throw an
* error.
@davidmurdoch
davidmurdoch / ini.ts
Created March 5, 2024 21:22
A TypeScript generator function that parses the given ini file (as a buffer) into sections, keys, and values (not tested, just for fun)
/**
* Enum representing the possible states of the parser.
*/
enum State {
Start,
Key,
Value,
Comment,
}