Skip to content

Instantly share code, notes, and snippets.

Ryan Nutt RyanNutt

Block or report user

Report or block RyanNutt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
RyanNutt / preg_search
Last active Aug 29, 2015
One liner to get RegEx matches in PHP
View preg_search
RyanNutt / Rotate a string
Created Sep 28, 2014
I needed an easy way to rotate a string a set number of places for a lab I was setting up. This returns s rotated by distance spots and loops back around.
View Rotate a string
private String rotateString(String s, int distance) {
String out = "";
for (int i=0; i<s.length(); i++) {
out += s.charAt((i + distance) % s.length());
return out;
RyanNutt /
Last active Oct 4, 2015
I use a lot of parameterized JUnit tests in class and got tired of copying and pasting an existing full test file and then deleting the pieces I don't need. This one is pretty much cut down to the minimum.
import java.lang.reflect.Field;
import java.util.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
RyanNutt / pin_it.js
Created Nov 1, 2014
Pin to Pinterest from command line with node
View pin_it.js
var PinIt = require('pin-it-node');
var pinIt = new PinIt({
username: 'your_pinterest_username',
password: 'your_pinterest_password'
var settings = {
boardId: 'Numeric_board_id',
url: process.argv[2],
View moodle-quiz-count.sql
SELECT u.lastname, u.firstname, u.idnumber,
FROM prefix_quiz_attempts attempts
JOIN prefix_quiz quiz
JOIN prefix_course_modules cm
RyanNutt /
Created Sep 24, 2015
Git command to export a repository into a zip file with prefix. Can use this to create zip files from GitLab archives maybe???
git archive --format=zip --prefix=foldername/ >
RyanNutt / del_recursively
Last active Sep 27, 2015
Delete all files by extension recursively. This one was to delete all flac files out of a set of folders after converting to mp3.
RyanNutt / base64_maybe.php
Created Oct 3, 2015
Function to base64 decode a string if it appears to be base64 encoded, or returns the string unchanged if it doesn't look like it's encoded.
View base64_maybe.php
function base64_decode_maybe($str) {
if (base64_encode(base64_decode($str, true)) == $str) {
return base64_decode($str);
return $str;
RyanNutt / hideGutter.js
Created Oct 4, 2015
Hide line number gutter from Ace editor
View hideGutter.js
var edit = ace.edit('editorDiv');
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
You can’t perform that action at this time.