Skip to content

Instantly share code, notes, and snippets.

@RyanNutt
RyanNutt / github-classroom-travis-badge.js
Created November 15, 2019 14:04
Tapermonkey script to add Travis CI badges to GitHub Classroom
// ==UserScript==
// @name GitHub Classroom Badges
// @namespace https://compsci.rocks/
// @version 0.1
// @description Add Travis build badges to repos in GitHub Classroom
// @author Ryan Nutt
// @website https://compsci.rocks/
// @include /^https?://classroom\.github\.com/classrooms/(.*)?/(group-)?assignments/(.*)?
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
@RyanNutt
RyanNutt / jQ-window-opener.js
Created October 22, 2019 13:32
Needed a way to reference a form on the window that opened a JavaScript pop-up. This seems to work, although there's probably a better way.
<script type="text/javascript">
$(window.opener.document).find('[name="assignment-name"]').val('Hello, is this thing on?');
</script>
@RyanNutt
RyanNutt / nb-jquery-ajax.js
Last active October 19, 2019 14:35
NetBeans code template for jQuery Ajax call.
jQuery.ajax(url, {
method: 'POST',
data: {
},
beforeSend: function (xhr, settings) {
},
complete: function (xhr, status) {
},
@RyanNutt
RyanNutt / readme.md
Created August 1, 2019 21:20
Get a "web safe" color based on string contents in PHP

Get color for string in PHP

I've needed to do this a couple of times, so I guess it's time to save it as a Gist for next time.

What I needed was a way to calculate a color based on string contents, where the same string would always generate the same color. I also wanted the colors generated to be part of the web safe palette. Not that there's any reason to stay in that palette for browsers now, but I wanted to keep the possible palette relatively small and have colors that generally look okay together. The math behind the web safe palette made it pretty easy.

As it works out, all of the web safe colors are multiples of 51. We'll need that bit of trivia in a second...

@RyanNutt
RyanNutt / popular_authors.php
Last active July 31, 2019 19:55
Laravel Eloquent query to pull the authors with the most posts connected by a hasMany relationship
@RyanNutt
RyanNutt / test_hook.sh
Created January 20, 2019 22:34
WP-CLI command to test WordPress actions from the command line
wp eval "do_action('action_name');" --path=/path/to/htdocs --url=https://website.domain
@RyanNutt
RyanNutt / extra-style.css
Created February 12, 2019 18:05
Extra CSS styling for WordPress TwentyNineteen theme that changes archive pages into grid layouts without changing the underlying theme files. You can see what it looks like at https://brickzone.club
body.blog #main,
body.archive #main {
display: grid;
grid-template-columns: 32% 32% 32%;
}
@media (max-width: 400px) {
body.blog #main,
body.archive #main {
grid-template-columns: 100%;
add_shortcode('permalink', function() {
return get_permalink();
});
@RyanNutt
RyanNutt / RemoveWPEmoji.php
Created December 20, 2018 15:05
Removes the WP Emoji JS from WordPress site - from https://www.denisbouquet.com/remove-wordpress-emoji-code/
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@RyanNutt
RyanNutt / !readme.md
Last active November 2, 2018 16:51
Move Canvas files from download package to individual folders for each student and keep original filenames . https://compsci.rocks

Move Canvas Files

Canvas is good for a lot of things, but turning in source code in a computer science class is not one of them.

Our district requires us to use Canvas, and for the most part that's a good thing. But when students need to turn in Java files there's a pretty significant issue. When you download submitted files they've all been renamed and stored in the root of the zip file.

Since they're Java files, they need to be named the same thing as the class which breaks by renaming the files

A Bit of Python