Skip to content

Instantly share code, notes, and snippets.

View JohnStarich's full-sized avatar

John Starich JohnStarich

View GitHub Profile
@JohnStarich
JohnStarich / 0-Linux Disk Benchmark.md
Created January 2, 2025 08:58
Linux Disk Benchmark

Linux Disk Benchmark

Runs fio to benchmark similar metrics to KDiskMark and CrystalDiskMark.

This produces results like the one below for easy comparison to existing tools, though when a GUI is not available or convenient.

fiotest-1024m:
Benchmark           Bandwidth
Read-Seq1M-Q8T1 5518 Mbps ( 690 IOPS)
@JohnStarich
JohnStarich / fast-videos.js
Created February 28, 2024 00:19
fast-videos-bookmarklet
javascript:(function() {
const videos =
Array.from(document.querySelectorAll('video'))
.concat(
Array.from(document.querySelectorAll('iframe'))
.flatMap(doc =>
Array.from(
doc.contentDocument.querySelectorAll('video')
)
)
@JohnStarich
JohnStarich / show-github-comments-resolved-by-others.js
Last active December 14, 2023 05:28
Show all hidden GitHub comments that were resolved by someone else
javascript:(function() {
/*
To use this bookmarklet, create a new bookmark in your browser and paste
the entire contents of this file into the URL address box.
*/
const username = document.head.querySelector('meta[name="user-login"]').content;
const currentUsersReviews = Array.from(document.querySelectorAll('.timeline-comment.current-user'))
.map(e => document.getElementById(e.id)); /* find our reviews, then get parent container */
const comments =
@JohnStarich
JohnStarich / unroll-github-comments-bookmarklet.js
Last active October 3, 2023 12:09
Load all collapsed GitHub comments
javascript:(function() {
/*
To use this bookmarklet, create a new bookmark in your browser and paste
the entire contents of this file into the URL address box.
*/
let emptyMillis = 0;
const delayMillis = 250;
const interval = setInterval(() => {
const elems = document.querySelectorAll('.pagination-loader-container button[type="submit"]');
@JohnStarich
JohnStarich / chrome-no-cors.sh
Created July 4, 2022 20:48
Starts Google Chrome without CORS restrictions for local development.
#!/usr/bin/env bash
# Currently works on macOS. Can work with other OS's if the path to
# Chrome's (or Chromium's) executable is changed.
dir=~/.config/chrome-no-cors
mkdir -p "$dir"
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
--disable-web-security \
--user-data-dir="$dir" \
@JohnStarich
JohnStarich / hackpad_errors.go
Created February 20, 2022 05:36
HackpadFS article – HackpadFS common error types
var (
ErrInvalid = syscall.EINVAL
ErrPermission = fs.ErrPermission
ErrExist = fs.ErrExist
ErrNotExist = fs.ErrNotExist
ErrClosed = fs.ErrClosed
ErrIsDir = syscall.EISDIR
ErrNotDir = syscall.ENOTDIR
ErrNotEmpty = syscall.ENOTEMPTY
@JohnStarich
JohnStarich / hackpad_helpers.go
Created February 16, 2022 06:09
HackpadFS article – HackpadFS helpers
// Equivalent helpers to io/fs
func ReadDir(fs FS, name string) ([]DirEntry, error)
func ReadFile(fs FS, name string) ([]byte, error)
func Stat(fs FS, name string) (FileInfo, error)
func Sub(fs FS, dir string) (FS, error)
func WalkDir(fs FS, root string, fn WalkDirFunc) error
// New FS helpers
func Chmod(fs FS, name string, mode FileMode) error
func Chown(fs FS, name string, uid, gid int) error
func Chtimes(fs FS, name string, atime time.Time, mtime time.Time) error
@JohnStarich
JohnStarich / hackpad_go_helpers.go
Created February 16, 2022 06:06
HackpadFS article – Base Go helpers
func Glob(fs FS, pattern string) (matches []string, err error)
func ReadDir(fs FS, name string) ([]DirEntry, error)
func ReadFile(fs FS, name string) ([]byte, error)
func Stat(fs FS, name string) (FileInfo, error)
func Sub(fs FS, dir string) (FS, error)
func WalkDir(fs FS, root string, fn WalkDirFunc) error
@JohnStarich
JohnStarich / hackpad_fs_interfaces.go
Created February 16, 2022 06:01
HackpadFS article – HackpadFS extension interfaces
// Equivalent interfaces to io/fs
type FS = fs.FS
type FileInfo = fs.FileInfo
type DirEntry = fs.DirEntry
type File = fs.File
// New FS interfaces:
type SubFS interface { FS; Sub(dir string) (FS, error) }
type OpenFileFS interface { FS; OpenFile(name string, flag int, perm FileMode) (File, error) }
type CreateFS interface { FS; Create(name string) (File, error) }
type MkdirFS interface { FS; Mkdir(name string, perm FileMode) error }
@JohnStarich
JohnStarich / hackpad_go_fs_interfaces.go
Last active February 16, 2022 05:59
HackpadFS article – Base Go interfaces
type FS interface {
Open(name string) (File, error)
}
type File interface {
Stat() (FileInfo, error)
Read(p []byte) (int, error)
Close() error
}
type FileInfo interface {
Name() string