Skip to content

Instantly share code, notes, and snippets.

View bryanmr's full-sized avatar

Bryan bryanmr

  • Durham
View GitHub Profile
/* exported fetchComments */
'use strict';
/** Fetches Reddit comment thread and then writes it to console
* @param {string} siteURL - URL of the post we are checking for */
exports.fetchComments = () => {
const siteURL = process.env.site_url;
const bucketName = process.env.bucket_short_name;
const bucketDir = process.env.bucket_dir;
const {Storage} = require('@google-cloud/storage');
@bryanmr
bryanmr / bash_document_functions.sh
Created March 4, 2019 18:24
A little (incomplete) script I wrote to document functions in a Bash script
#!/bin/bash
# Script to produce documentation skeleton
oops() {
echo "Exit Code: $? ~~ Command before oops: $this_command"
tput bold
echo "$@"
tput sgr0
exit 1
}
main_function_calls() {
@bryanmr
bryanmr / strip_old_images.sh
Last active March 2, 2019 15:32
A quick awk thing I wrote to strip out dead links for images from Jekyll posts
#!/bin/bash
rm -rf /var/tmp/cleaned_posts
mkdir -p /var/tmp/cleaned_posts
while read -r post ; do
awk '/image:/ { our_image=$2 } /<img class/ { print "![For the Cure of Text](" our_image ")";next } { print $0 }' "$post" > /var/tmp/cleaned_posts/"$post"
done <<< "$(find . -name "*.md")"
@bryanmr
bryanmr / patcher.sh
Created February 21, 2019 22:41
Failed experiment with generating patches
#!/bin/bash
if [ "$1" == "--patcher" ] ; then
find diffs/ -type f -exec patch {} {} ';'
elif [ "$1" == "--diff" ] ; then
rm -rf diffs~
mv diffs diffs~
diff -r mediumish-theme-jekyll/ dist/ | grep -v '^Only in' |\
awk '/^diff -r / { gather=1 ;
target=$4 ;
@bryanmr
bryanmr / reddit_search_parse.js
Last active February 1, 2019 18:57
A simple NodeJS script to parse out the permalink and title from Reddit search
// https://www.reddit.com/r/linux_gaming/search.json?q=author%3Abryanindurham&restrict_sr=1
// https://www.reddit.com/wiki/search
// Get Command Line Arguments
filename=process.argv[2];
console.log("Checking: " + filename);
// Read the file from command line
fs = require('fs')
fs.readFile(filename, 'utf8',