Skip to content

Instantly share code, notes, and snippets.

View morningtoast's full-sized avatar

Brian Vaughn morningtoast

View GitHub Profile
@morningtoast
morningtoast / ci-htaccess
Last active October 13, 2015 17:57
htaccess for CodeIgniter
RewriteEngine on
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
@morningtoast
morningtoast / jq-plugin-template
Last active October 13, 2015 18:08
jQuery plugin template
jQuery(function($){
function debug(str) {
if (settings.debug) { console.log(str); }
}
// Helper methods
var helper = {
};
@morningtoast
morningtoast / js-module
Created June 17, 2013 14:19
JS Module Pattern
var MyModule = (function($, Modernizr) {
// Module variables. Use for local tracking
var data = {
}
// Module init; This will run during onready if module is defined in the <body> data attribute
var init = function() {
_debug("main.init()");
@morningtoast
morningtoast / scratch-work
Last active December 18, 2015 17:19
Scratch work
// Tiny selector - Callback is passed all matching elements
// $m(parent, tagName, [className,] callback)
function $m(p, tn, cn, cb) {
if (typeof p === "string") { var p = document.getElementById(p); }
var l = p.getElementsByTagName(tn);
for (a=0; a < l.length; a++) {
if (typeof cn === "function") {
cn(l[a]);
@morningtoast
morningtoast / airport-gen
Created June 21, 2013 14:32
Airport code generator
<?
echo SKU_gen('Factory Town', 13, 2).'<br>'; // zrgr-0013
echo SKU_gen('Stronghold', 13, 2).'<br>'; // zrgrn-0013
echo SKU_gen('Ice Palace', 14, 2).'<br>'; // glc-0014
echo SKU_gen('Twin Pits', 15, 3).'<br>'; // cz-0015
echo SKU_gen('Rainbow Farms', 20).'<br>'; // kz-0020
echo SKU_gen('The Great Chasm', 20).'<br>'; // kz-0020
echo SKU_gen('Ranch', 20).'<br>'; // kz-0020
echo SKU_gen("Brad's Lighthouse", 20).'<br>'; // kz-0020
echo SKU_gen("Train Station", 20).'<br>'; // kz-0020
@morningtoast
morningtoast / off-canvas
Created June 21, 2013 20:14
Off canvas menu
<!doctype html>
<html class="no-js" lang="en">
<head>
<title>Off Canvas Page Slide / Fly-Out Navigation Example | Responsive Navigation</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@morningtoast
morningtoast / single-mod-template
Created July 16, 2013 19:16
JS Standalone Module Template
/*
JS Standalone Module Template
Replace MYCLASS with your desired class name
Anything declared using MYCLASS will be public
*/
(function() {
var self = this;
var MYCLASS;
@morningtoast
morningtoast / dom-select
Last active December 20, 2015 10:30
DOM Selector
// Tiny selector - Callback is passed all matching elements
// $m(parent, tagName, [className,] callback)
function $m(p, tn, cn, cb) {
if (typeof p === "string") { var p = document.getElementById(p); }
var l = p.getElementsByTagName(tn);
for (a=0; a < l.length; a++) {
if (typeof cn === "function") {
cn(l[a]);
@morningtoast
morningtoast / gdresize
Created August 7, 2013 20:04
PHP GD resizing, upscaling
function generate_image_thumbnail($source_image_path, $thumbnail_image_path, $max_width, $max_height, $quality=35) {
list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path);
switch ($source_image_type) {
case IMAGETYPE_GIF:
$source_gd_image = imagecreatefromgif($source_image_path);
break;
case IMAGETYPE_JPEG:
$source_gd_image = imagecreatefromjpeg($source_image_path);
break;
case IMAGETYPE_PNG:
@morningtoast
morningtoast / os-gitignore
Created August 20, 2013 15:07
Default ignore
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.Spotlight-V100
.Trashes
Thumbs.db
ehthumbs.db
Desktop.ini