Skip to content

Instantly share code, notes, and snippets.

@RyanNutt
RyanNutt / embed.html
Created October 20, 2015 15:36
Needed a way to embed a Gist in an Instructure Canvas page. Just paste this into when in HTML editing mode and switch out the address with your gist. CSS came from http://www.bymichaellancaster.com/blog/fluid-iframe-and-images-without-javascript-plugins/
<p style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
<iframe style="position: absolute; top: 0; height: 100%; width: 100%;" src="https://gist.github.com/RyanNutt/905983e76c20cf3177b7.pibb" width="300" height="150">
</iframe>
</p>
@RyanNutt
RyanNutt / WebSafe.php
Last active November 27, 2015 13:39
PHP script to return the hex codes of the 216 "web safe" colors
<?php
function web_safe_colors() {
$ray = array();
$steps = array(
'00',
'33',
'66',
'99',
'cc',
'ff' );
@RyanNutt
RyanNutt / .htaccess
Created November 30, 2015 00:11
ExpiresByType for .htaccess to define browser cache expiration; got tired of having to google for it;
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
<?php
require_once(__DIR__.'/vendor/autoload.php');
use Jaguar\Canvas,
Jaguar\Coordinate,
Jaguar\Color\RGBColor,
Jaguar\Drawable\Rectangle;
$canvas = new Canvas('image.jpg');
@RyanNutt
RyanNutt / AceError.js
Created January 1, 2016 21:14
Got tired of the error from Ace editor about changing $blockScrolling to Infinity so did some Googling. Saving it here so I don't have to go as far to look next time. From http://stackoverflow.com/questions/28936479/where-to-set-ace-editor-blockscrolling
var el = $(the_element);
var editor = el.data('ace').editor;
editor.$blockScrolling = Infinity;
truncate -s 0 {filename.txt}
ls -lh filename.txt
truncate -s 0 filename.txt
ls -lh filename.txt
var new_select = jQuery('<select>', {
class: 'some-class-name'
});
var new_select = jQuery('<select>', {
'class': 'some-class-name'
});
@RyanNutt
RyanNutt / BuildStringMatrix.java
Created February 7, 2016 15:33
Quick method to take a string and build a square matrix. This assumes that data.length() is a perfect square. The resultant matrix will be sqrt(length) x sqrt(length).
private String[][] buildStringMatrix( String data ) {
int size = (int) (Math.sqrt( data.length() ));
String[][] out = new String[ size ][ size ];
for ( int r = 0; r < out.length; r++ ) {
for ( int c = 0; c < out[ r ].length; c++ ) {
int idx = (r * out[ r ].length) + c;
out[ r ][ c ] = data.substring( idx, idx + 1 );
}
SELECT CONVERT_TZ(displaytime,'GMT','MET');