Skip to content

Instantly share code, notes, and snippets.

View JohnStarich's full-sized avatar

John Starich JohnStarich

View GitHub Profile
@JohnStarich
JohnStarich / persistent_thread_pool.py
Last active September 24, 2022 10:01
Creates a multiprocessing.pool.ThreadPool with persistent resources in order to reduce spin up time of tasks submitted to the pool
#!/usr/bin/env python3
"""
Demonstration of creating a multiprocessing.pool.ThreadPool where
persistent resources are necessary to reduce spin up time of tasks submitted to
the pool.
The PersistentObject supports with statement contexts to show it can clean up
properly after it is told to recycle.
"""
@JohnStarich
JohnStarich / notes
Last active December 26, 2018 07:52
A handy script to quickly begin writing notes in your favorite editor for any given subject. Useful for writing notes in school for multiple subjects.
#!/usr/bin/env python3
from configparser import ConfigParser
from datetime import datetime
from os import path
import argparse
import itertools
import os
import re
@JohnStarich
JohnStarich / pdfify
Last active February 5, 2017 11:00
Convert and concatenate all arguments into a single PDF (Mac only for the moment)
#!/bin/bash
set -e
function usage() {
echo "Usage: $(basename $0) FILE [FILE [FILE ...]]" >&2
}
# Validate args
@JohnStarich
JohnStarich / device_sim.py
Created July 13, 2017 01:10
A device simulator. Devices must not be run concurrently, but all jobs should be run in a distributed fashion.
#!/usr/bin/env python3
# This solution randomly assigns each job to a device
# and then groups jobs by device ID. Each of these groups
# is then submitted to a proccessing pool. Whichever worker
# finishes first grabs the next group to process.
from __future__ import print_function
from multiprocessing.pool import Pool
import random
@JohnStarich
JohnStarich / scaladoc-tutorial.md
Last active August 16, 2023 12:56 — forked from VladUreche/gist:8396624
Scaladoc tutorial for docs.scala-lang.org

Scaladoc Developer Guide

Introduction

Scaladoc is the tool that enables developers to automatically generate documentation for their Scala (and Java) projects. It is Scala's equivalent of the widely-used Javadoc tool. This means that Javadoc (and even doxygen) users will be familiar with Scaladoc from day 1: for them, it is most beneficial to check out the Scaladoc/Javadoc comparison tables and if necessary, skim through this document to understand specific features.

The rest of this tutorial is aimed at developers new to Scaladoc and other similar tools. It assumes a basic understanding of the Scala language, which is necessary to follow the examples given throughout the tutorial. For the user perspective on the scaladoc-generated documentation, such as finding a class, understanding the page layout, navigating through diagrams, please refer to the Scaladoc User Guide.

The tutorial will start by a short motivation and then will explain the main concept in Scaladoc: the doc comment.

Contents

@JohnStarich
JohnStarich / pipe.go
Last active January 4, 2020 19:03
Functional Pipes in Go
package pipe
// Op is the common pipe operation. Can be composed into Ops and run as a single unit
type Op interface {
Do() error
}
// OpFunc makes it easy to wrap an anonymous function into an Op
type OpFunc func() error
@JohnStarich
JohnStarich / keychain-search.md
Last active November 23, 2020 13:27
keychain-search.sh

Keychain Search script

I found it difficult to search through the iCloud keychain for thousands of potentially breached domain names, like the Cit0day dump.

Turns out iCloud keychain is especially difficult to search through for website domains compared to the login or System keychains.

I made this script to open up the keychain app on macOS and search for any number of domains in a giant file, then print out the possibly affected domains.

@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
@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_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