Skip to content

Instantly share code, notes, and snippets.

View shakyShane's full-sized avatar

Shane Osbourne shakyShane

View GitHub Profile
@shakyShane
shakyShane / base.php
Created July 22, 2012 09:35
Handle page requests in laravel controller
/**
*
* 1. Check if it's an ajax request
* 2. Set up Page Data (title, activenav etc)
* 3. add any addtional data to be passed to the View.
* @param $route
* @return mixed
*
*
*/
@shakyShane
shakyShane / base.php
Created July 22, 2012 09:36
boilerplate for a Laravel Base Controller
<?php
class Base_Controller extends Controller {
public $layout = 'layouts.main';
public function __construct(){
//Styles
Asset::add('css', 'css/main.css');
@shakyShane
shakyShane / Helpers.php
Created July 22, 2012 09:43
Convert a 'route' into a page title
<?php
/**
* Convert a 'route' into a page title.
*
* @static
* @param $route
* @return string
*
*/
public static function setTitle($route){
@shakyShane
shakyShane / custom.0.1.js
Created July 30, 2012 18:31
Helper method to show/hide a menu & update an Icon with Twitter Bootstrap
$('.action').on('click', function(){
var icon = $(this).find('i');
var toggleIcon = function (){
var newIcon = (icon.hasClass('icon-plus')) ? 'icon-minus' : 'icon-plus' ;
icon.removeClass('icon-plus icon-minus');
icon.addClass(newIcon);
}
toggleIcon();
var action = $(this).data('action');
var elem = $(this).data('elem');
@shakyShane
shakyShane / vert-grad
Created August 4, 2012 09:13
mixin-vert-grad
@mixin vert_gradient($start, $finish){
background: $start; /* Old browsers */
background: -moz-linear-gradient(top, $start 1%, $finish 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,$start), color-stop(100%,$finish)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, $start 1%,$finish 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, $start 1%,$finish 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, $start 1%,$finish 100%); /* IE10+ */
background: linear-gradient(top, $start 1%,$finish 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = #{$start}, endColorstr = #{$finish}, GradientType = 0);
@shakyShane
shakyShane / BootstrapForm.php
Created August 5, 2012 18:47
Twitter Bootstrap Form Generator PHP.
<?php
/**
*
* Helper Class to output correct Twitter Bootstrap Markup.
* Only option for now is the horizontal Form.
*
* Usage :
*
$form = new BootstrapForm('add_user');
$form->addInput('text-input', 'user_name', 'Your name:', true);
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@shakyShane
shakyShane / _style.scss
Created August 19, 2012 20:32
Boilerplate CSS for Horizontal Nav Menus
#mainNav { display: inline-block; list-style: none;}
#mainNav li { float: left; }
#mainNav li a { display: inline-block; padding: 20px;}
#mainNav li a:hover { background: blue;}
@shakyShane
shakyShane / _mixins.scss
Created August 19, 2012 20:59
SASS Mixins - frequently used
@mixin vert_gradient($start, $finish){
background: $start; /* Old browsers */
background: -moz-linear-gradient(top, $start 1%, $finish 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,$start), color-stop(100%,$finish)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, $start 1%,$finish 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, $start 1%,$finish 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, $start 1%,$finish 100%); /* IE10+ */
background: linear-gradient(top, $start 1%,$finish 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = #{$start}, endColorstr = #{$finish}, GradientType = 0);
@shakyShane
shakyShane / category.php
Created September 4, 2012 20:29
Create a Permalink from a page title - Laravel
<?php
class Category extends Eloquent
{
/**
* -----------------------------------
* Make Permalink from a Title.
* -----------------------------------
*