Skip to content

Instantly share code, notes, and snippets.

View beporter's full-sized avatar

Brian Porter beporter

View GitHub Profile
@beporter
beporter / asins.php
Last active July 7, 2017 19:59
(Crudely) collect Amazon ASINs from URLs
<?php
/**
* Quick script to extract ASINs from Amazon URLs.
*
* @see http://stackoverflow.com/a/12827734/70876
*
* beporter at users dot sourceforge dot net
* 2016-05-18
*/
@beporter
beporter / md5-compare.sh
Last active August 20, 2019 13:34
Compare a known md5 hash against that of a downloaded file.
#!/user/bin/env bash
# $1 = file to digest
# $2 = expected hash
# Exits zero if the hashes match, outputs the difference if they do not and exits non-zero.
diff \
<(md5 ${1?"Provide a valid file path as the first argument."} | cut -f 4 -d ' ' -) \
<(echo ${2?"Provide the expected md5 hash as the second argument."})
@beporter
beporter / belongstomany-patch.sh
Created November 2, 2015 15:57
A quick diff and script to resolve cakephp/cakephp#7626 until that PR can be merged. Save these files in your project root dir, make the .sh executable, and run it. Assumes CakePHP v3.1.3 is in use.
#!/usr/bin/env bash
#---------------------------------------------------------------------
usage ()
{
cat <<EOT
${0##*/}
Apply the belongstomany.patch file to your cakephp source in vendor/
@beporter
beporter / thumbs.php
Last active April 19, 2022 09:23
A quick PHP script to generate a folder of thumbnails from a source folder of JPG image files. PHP must be able to write files to the local directory.
<?php
// Make sure we see processing errors during development/testing.
error_reporting(E_ALL);
ini_set('display_errors', true);
// Set up operating parameters.
$filePattern = 'gallery/*.[jJ][pP][gG]';
$thumbPattern = 'thumbs/%s';
$targetWidth = 200;
@beporter
beporter / composer
Last active September 11, 2015 18:55
A wrapper script for composer that recognizes a COMPOSER_NODEV environment variable. See: https://github.com/composer/composer/issues/4408
#!/usr/bin/env bash
# beporter@users.sourceforge.net
#---------------------------------------------------------------------
usage ()
{
cat <<EOT
${0##*/}
Wrapper around composer to make it "aware" of a custom
@beporter
beporter / weekbyweek.php
Created September 2, 2015 23:10
A quick command line PHP script to scrape "week by week" pregnancy updates from thebump.com's API into local .html files.
<?php
/**
* A command line script to grab the "week-by-week" updates from
* TheBump.com's API and save them to local .html files.
*
* Tries to be respectful and cache all results to avoid unecessary HTTP
* calls. Uses the API key that thebump.com's own website uses. No malice
* is intended by this.
*
* Usage:
@beporter
beporter / sfcvs2git.sh
Last active August 29, 2015 14:27
A script to automate converting a SourceForge.net CVS repo into a git repo.
#!/usr/bin/env bash
#
#---------------------------------------------------------------------
usage ()
{
cat <<EOT
${0##*/}
Wraps up the commands required to dump a SourceForge CVS repo
@beporter
beporter / git-find-repos
Created August 10, 2015 22:04
Find all git repos (folders containing a `.git/` subdirectory) in the provided path (defaults to current directory.)
#!/usr/bin/env bash
#
# Find and list all git repos (folders containing .git/ directories)
# in the provided path (defaults to current dir.)
#
# Designed to run on a Mac, so make sure you have GNU `findutils`
# and the `terminal-notifier` gem installed.
#
# beporter@users.sourceforge.net
# v1.0 2015-08-10
@beporter
beporter / git-deploy
Last active June 9, 2016 18:02
A git add-on script that automates fast-forwarding branches to each other, pushing to the default remote (origin) and triggering pre/post scripts. Read `usage()` for details.
#!/usr/bin/env bash
#
# https://gist.github.com/beporter/8074237fa5a71f77dc5c
# beporter@users.sourceforge.net
# 2015-09-14
#---------------------------------------------------------------------
usage ()
{
@beporter
beporter / composer-create-project-test.sh
Last active January 9, 2020 20:28
Make the process of testing a `composer create-project` command easier by operating against your local working copy.
#!/usr/bin/env bash
# Allows you to test the create-project process using your local
# checked-out copy of the skeleton as the source. You MUST commit the
# changes you want to test to a git branch! You MUST name that branch
# as the first argument and the destination path to set up the fresh
# copy into as the second.
#
# Usage:
# - Place this script in your package's root directory and make it executable.
# - Set the PACKAGE_NAME variable below to match your composer.json's `name`.