Skip to content

Instantly share code, notes, and snippets.

@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 / 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%;
@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
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

@RyanNutt
RyanNutt / md2docx.bat
Last active September 3, 2018 22:00
Convert all markdown files in a folder to docx with MathJax rendered as image instead of as Microsoft equations. https://compsci.rocks/markdown-mathjax-word-embedded-images/
@echo off
for %%f in (*.md) do (
echo Converting %%~nf.md to %%~nf.docx
pandoc "%%~nf.md" --webtex -t html | pandoc -f html -o "%%~nf.docx"
)
@RyanNutt
RyanNutt / pandoc.cmd
Last active September 2, 2018 14:46
Pandoc command that's supposed to take a markdown file with embedded MathJax and create a Word file with the equations rendered as images. From https://groups.google.com/forum/#!topic/pandoc-discuss/CvnPIiWUc-Q
pandoc filename.md --webtex -t html | pandoc -f html -o filename.docx
@RyanNutt
RyanNutt / Jeroo.java
Last active September 3, 2018 22:11
Mockup of a Jeroo class file. See https://compsci.rocks/jeroo-demo-class-file/
public class Jeroo {
private int row;
private int column;
private int flowers;
public Jeroo() {}
public Jeroo(int flowers) {}
public Jeroo(int row, int col) {}
public Jeroo(int row, int col, int flowers) {}
@RyanNutt
RyanNutt / MonkeyHelloWorld.java
Last active May 10, 2018 16:05
Monkeys banging on a keyboard to solve Hello World - https://clsc.be/21
public class MonkeyHelloWorld {
public static void main( String[] args ) {
String target = "Hello World";
String discovered = "";
long counted = 0l;
do {
counted++;
discovered = randomString();