Skip to content

Instantly share code, notes, and snippets.

@aws-john
Last active March 11, 2021 19:32
Show Gist options
  • Save aws-john/1639a7b9a96696284896b76362199216 to your computer and use it in GitHub Desktop.
Save aws-john/1639a7b9a96696284896b76362199216 to your computer and use it in GitHub Desktop.
AWS on StackOverflow: Useful resources

AWS on StackOverflow

by John Rotenstein (jorote.at.amazon.com)
Broadcast from Sydney, Australia

Companion information for the show on Twitch.

StackOverflow

My YouTube Channel: CQ_John

  • Youtube: CQ_John
  • Contains episodes of the CQ Cert Quiz Show, Developers Let's Code, etc.

StackOverflow reporting

Live Coding

Chrome extensions

Tampermonkey scripts

Find bad tags:

// ==UserScript==
// @name       [StackOverflow] Highlight bad tags
// @version    1.0
// @description  Highlight listed tags
// @match      https://stackoverflow.com/*
// ==/UserScript==

var tagsToHighlight = ['amazon', 'aws-athena', 'aws-kinesis-firehose', 'lambda', 'ses', 'rds', 'cognito', 'aws-sqs', 'awss3',
                       'cloud9', 's3-bucket', 'aws-vpc-link', 'glue', 'sns', 'lex', 'amazon-dax', 'aws-comprehend', 'aws-glue-job'];

    var tags = $(".post-tag");

    $.each(tags,
           function (index)
           {
               if (-1 != $.inArray(tags[index].text, tagsToHighlight))
                   tags[index].style.backgroundColor='red';
           });

Replace bad tags:

// ==UserScript==
// @name       [StackOverflow] Burn/replace tags
// @version    1.0
// @description  Replace/Delete tags
// @match      https://stackoverflow.com/questions/*
// ==/UserScript==

// Only run on pages with questions (question number in URL)

if ('0123456789'.indexOf(window.location.pathname.charAt(11)) === -1) return;

function exec(fn) {
    var script = document.createElement('script');
    script.setAttribute("type", "application/javascript");
    script.textContent = '(' + fn + ')();';
    document.body.appendChild(script); // run the script
    document.body.removeChild(script); // clean up
}

window.addEventListener("load", function () {

    // script injection
    exec(function () {

    /* add other tags that should get REMOVED but don't indicate the question is deletable */
    var tagsThatShouldJustBeRemoved = ["amazon"];
    var tagsToReplace = {'aws-athena':'amazon-athena', 'aws-kinesis-firehose':'amazon-kinesis-firehose', 'lambda':'aws-lambda',
                         'amazon':'amazon-web-services', 'ses':'amazon-ses', 'rds':'amazon-rds', 'cognito':'amazon-cognito',
                        'aws-sqs':'amazon-sqs', 'awss3':'amazon-s3', 'cloud9':'aws-cloud9', 's3-bucket':'amazon-s3',
                        'aws-vpc-link':'amazon-vpc', 'glue':'aws-glue', 'sns':'amazon-sns', 'lex':'amazon-lex', 'amazon-dax':'amazon-dynamodb-dax',
                        'aws-comprehend':'amazon-comprehend', 'aws-glue-job': 'aws-glue'};
    var tags = $(".post-taglist .post-tag").map(function () { return $(this).text(); }).get();
    var toSave = [];

    $.each(tags,
           function (index)
           {
               if (tags[index] in tagsToReplace)
                   toSave.push(tagsToReplace[tags[index]]);
               else if ($.inArray(tags[index], tagsThatShouldJustBeRemoved) === -1)
                   toSave.push(tags[index]); // save it
           });

    // No change? Exit!
    if (toSave.toString() == tags.toString()) return;

    // No tags? Tell user.
    if (toSave.length === 0){
        alert('This question has nothing but bad tags on it.  Either figure out a valid tag or flag and ask a mod to delete it if it is hopeless.');
        return;
    }

    var id = document.location.href.match(/\d+/);

    // Saves new tags
    $.ajax({
        type: "POST",
        url: "https://stackoverflow.com/posts/" + id + "/edit-tags",
        data: { fkey: StackExchange.options.user.fkey, tagnames: toSave.join(" ") },
        success: function (x, status, error)
        {
            // Indicate update by adding a * to title
            document.title = '*' + document.title;
        },
        error: function (x, status, error)
        {
            alert(status + "\\n" + error);
        },
    });

    });
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment