Skip to content

Instantly share code, notes, and snippets.

@jamietsao
jamietsao / concurrent_errors.go
Created August 25, 2017 00:16
golang: Pattern for concurrent processing and collecting errors when done
func ExecuteJobs(jobs []Job) []error {
var wg sync.WaitGroup
wg.Add(len(jobs))
// execute jobs concurrently
errChan := make(chan error)
for _, j := range jobs {
go func(j Job) {
defer wg.Done()
err := executeJob(j)
@jamietsao
jamietsao / git_move_files.sh
Last active September 2, 2015 18:07
Moving directory/files in Git while preserving history
################################################################################
# Moving files from one repo to another:
# http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
# filter one directory
git clone <git repository A url>
cd <git repository A directory>
git remote rm origin
git filter-branch --subdirectory-filter <directory 1> -- --all
mkdir <directory 1>
mv * <directory 1>