Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / randomizing-pipe-perl.sh
Last active May 29, 2020 03:21
A bash function for shuffling lines of input with optional repeatability.
#!/bin/bash
# randomizing_pipe()
#
# by Carlos McEvilly
# License: Apache
#
# A bash function wrapping a famous perl random shuffle, adding on
# the ability to pass in a fixed seed for repeatability.
#
@carlosmcevilly
carlosmcevilly / create-subset.sh
Last active June 28, 2018 03:40
Manage (create and delete) a throwaway subset/ directory containing some files copied from an existing source training/ directory.
#!/bin/bash
# create-subset.sh
#
# Create a throwaway subset/ directory containing files copied from an existing source
# training/ directory. Assumes .jpg. Once you are done with the (redundant) subset/ and
# want to clean it up, it's recommended to use remove-subset.sh instead of manual
# commands, since with these scripts we are operating close to training data and we
# don't want a mistake to result in the deletion of the wrong directory.
@carlosmcevilly
carlosmcevilly / partition-for-testing.sh
Last active July 3, 2018 16:58
Moves randomly selected 20% of your images out of an existing source training/ directory, into a new testing/ directory.
#!/bin/bash
# CAUTION: This is experimental. It's working well for me, but I may move to
# using symbolic links instead of doing this.
#
# partition-for-testing.sh
#
# Moves a percentage of your image data from subdirectories under training/
# to corresponding subdirectories under testing/, which it creates for you.
#
@carlosmcevilly
carlosmcevilly / td-make-random-backgrounds.sh
Last active June 26, 2020 06:21
Generate larger examples of the randomized background images from the ImageMagick examples site
#!/bin/bash
# td-make-random-backgrounds.sh
#
# Flatteringly adapted from the examples here:
# https://www.imagemagick.org/Usage/backgrounds/
#
# - credit goes to the above site for these examples
# - this covers all but the tiling examples
# - running multiple times gives different random output, overwriting each time
@carlosmcevilly
carlosmcevilly / gist:c7d695274e7ed8076b9ab4df5a797013
Created June 15, 2018 07:50
rmdir for macOS users (bash function)
function rmdir() {
[[ -e "$@/.DS_Store" ]] && /bin/rm "$@/.DS_Store"
/bin/rmdir "$@"
}
@carlosmcevilly
carlosmcevilly / hashit.sh
Last active September 11, 2019 15:55
hashit - wrapper around openssl providing easy command-line access to common hash functions
#!/bin/bash
# hashit - wrapper around openssl providing easy command-line access to common hash functions
#
# by Carlos McEvilly
#
# 'hashit' creates symlinks to itself, named after
# common hashing schemes, and then the script can
# be invoked via any so-named symlink with a text
# string or filename argument in order to obtain
@carlosmcevilly
carlosmcevilly / async_scraper.py
Created July 10, 2017 20:50 — forked from wtneal/async_scraper.py
asyncio scraper
import asyncio
import aiofiles
import aiohttp
import logging
import re
import sys
import os
import lxml.html
#!/bin/bash
# 1) edit the jira_base URL below
# 2) edit the project list below
# 3) save and make executable. Run in any directory where you have a branch named
# something like PROJ-1234. Browser opens with the JIRA ticket loaded.
export jira_base=https://jira.yourdomain.yourtld
export projects='(?:PROJ1|PROJ2)'
export jira=`git branch | grep '*' | perl -pe 's/.*?($ENV{'projects'}-\d+)\D?.*/$1/' -`
@carlosmcevilly
carlosmcevilly / branch.sh
Created February 6, 2017 22:16
Populate the clipboard (macOS) with the name of the current branch in your current directory
#!/bin/bash
export branch=`git branch | grep '*' | cut -c2-`
echo -n $branch | pbcopy
@carlosmcevilly
carlosmcevilly / elshirt.pl
Created March 5, 2016 04:42
El Shirt snake oil crypto submission
#!/usr/bin/perl -T # use -T because it makes things secure
use strict;
use warnings;
# El Shirt key preparation algorithm
#
# El Shirt is an anagram of SLITHER
#
# **** Background ****