Skip to content

Instantly share code, notes, and snippets.

View jackmcdade's full-sized avatar
🌴
🏝

Jack McDade jackmcdade

🌴
🏝
View GitHub Profile
Sed nec felis nulla! Etiam luctus luctus tellus consectetur accumsan. Etiam lacus neque; egestas non auctor sed, dapibus ac purus? Curabitur vitae enim magna. Praesent blandit tristique vulputate. Praesent id posuere eros! Nulla non quam et nisl vulputate adipiscing sed id nisl. Morbi venenatis, magna nec porta congue, dolor mi gravida lectus, nec imperdiet magna metus a felis. Ut tempor malesuada lorem; at pharetra erat egestas id. Duis leo quam, hendrerit ac sagittis nec, placerat quis dui. Pellentesque quis metus libero. Maecenas pharetra suscipit nunc scelerisque luctus. Nulla condimentum, mi cursus aliquam adipiscing, lectus felis laoreet eros, at fringilla ipsum erat vel magna!
@jackmcdade
jackmcdade / twitter-bootstrap2-with-structure.js
Created March 19, 2012 21:50
Twitter Bootstrap2 with Structure
{exp:structure:nav max_depth="2" show_depth="2" current_class="active" css_class="nav" has_children_class="dropdown"}
<script>
$(function() {
$('ul li.dropdown').each(function() {
$(this).children('ul').addClass("dropdown-menu"); // add children dropdown menu class
$(this).children('a').append('<b class="caret"></b>') // add caret icon
$(this).clone().prependTo($(this).find('ul')).removeClass('dropdown active').children('ul').remove(); // clone parent link into child menu
$(this).children('a').attr('data-toggle', 'dropdown').attr('href', '#').addClass("dropdown-toggle"); // add data attributes to hook up Bootstrap
});
@jackmcdade
jackmcdade / structure-entries.html
Created March 30, 2012 15:40
Structure flexible markup tag
<ul id="nav">
{exp:structure:entries}
<li class="top-level" id="{page_slug}"><a href="{page_url}">{title}</a>
{if children}
<ul class="dropdown">
{children limit_depth="2"}
<li class="level-{depth}"><a href="{page_url}">{title}</a>
{/children}
</ul>
{/if}
@jackmcdade
jackmcdade / gist:2509224
Created April 27, 2012 13:30
EE Mod Rewrite
AcceptPathInfo On
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
# Looks for files and directories that do not exist
# and provide the segments to the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
@jackmcdade
jackmcdade / meat-tornado
Created May 7, 2012 14:46
Statamic Exceprt
---
title : Meat Tornado
excerpt: Bacon ipsum dolor sit amet drumstick spare ribs pastrami ground round, jerky pork chuck pork chop ham hock tail corned beef chicken andouille tongue biltong. Venison short ribs swine meatball prosciutto strip steak pork, tongue pancetta ham jerky. Bacon pig filet mignon.
---
Bacon ipsum dolor sit amet drumstick spare ribs pastrami ground round, jerky pork chuck pork chop ham hock tail corned beef chicken andouille tongue biltong. Venison short ribs swine meatball prosciutto strip steak pork, tongue pancetta ham jerky. Bacon pig filet mignon brisket pork beef, meatball shoulder turkey swine tongue. Andouille sausage shankle, beef ribs pancetta pork loin corned beef flank brisket meatloaf ham hock short loin pastrami. Leberkas capicola tail pork belly rump, pig spare ribs pork.
Drumstick prosciutto tail, ham hock pork loin swine tongue frankfurter cow andouille shankle sausage chuck boudin. Ham hock rump ribeye pork belly ball tip, salami pig jerky. Tri-tip bacon tenderloin,
title: Big Healthy Green
ingredients:
- 6 to 8 kale leaves
- 2 to 4 stalks of celerey
- 3 to 4 carrots
- 2 apples
- 1 medium-sized cucumber
- 1 beet
- 1/2 lemon
directions: >
@jackmcdade
jackmcdade / gist:3138277
Created July 18, 2012 19:27
Add trailing slashes
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
@jackmcdade
jackmcdade / gist:3186283
Created July 27, 2012 05:17
Adding .html to the end of URLS
// Add the following after line 8 of _app/_routes.php
if (substr($path, -5) == '.html') {
$path = str_replace('.html', '', $path);
}
And use the following .htaccess rule before your index.php rewrite:
RewriteRule ^([^.]+)$ /$1.html [R=301,L]
@jackmcdade
jackmcdade / gist:3209202
Created July 30, 2012 19:03
Bad PHP Example
<?php
// Bad
$name = (!empty($_GET['name'])? $_GET['name'] : 'John');
// Good
// Some basic sanitization. Make sure to clean further if inserting into database
$name = (!empty($_GET['name'])? $_GET['name'] : 'John');
$name = strip_tags($name);
$name = htmlspecialchars($name, ENT_QUOTES);
@jackmcdade
jackmcdade / gist:3484008
Created August 26, 2012 22:44
Bash - archive to desktop
function zipit {
local filename=$1
if [ -z "$filename" ] ; then
filename=${PWD##*/}"-latest"
fi
git archive HEAD --format=zip > ~/Desktop/${filename}.zip
}