Skip to content

Instantly share code, notes, and snippets.

View raddevon's full-sized avatar

Devon Campbell raddevon

View GitHub Profile
@raddevon
raddevon / gist:5379208
Created April 13, 2013 17:04 — forked from mwcampbell/gist:5378578
Settings for www.raddevon.com to raddevon.com redirect in nginx
server {
listen 80;
server_name www.raddevon.com;
location / {
rewrite ^(.*)$ http://raddevon.com$1;
}
}
@raddevon
raddevon / colorSlide.js
Created May 16, 2013 12:43
A jQuery plugin that slides out a div the color of the trigger element's left border.
(function( $ ){
$.fn.colorSlide = function() {
var trigger = $(this);
var elWidth = trigger.outerWidth();
var elHeight = trigger.outerHeight();
var elPosition = trigger.offset();
var elColor = trigger.css('border-left-color');
trigger.find('a').css({
'position': 'relative',
@raddevon
raddevon / favicon.sublime-snippet
Created May 24, 2013 17:51
Sublime Text simple favicon snippet
<snippet>
<content><![CDATA[
<link rel="shortcut icon" href="${1:favicon.ico}">
]]></content>
<tabTrigger>favicon</tabTrigger>
<description>Favicon link tag</description>
<scope>text.html.basic</scope>
</snippet>
@raddevon
raddevon / touchClick.js
Created May 28, 2013 23:06
jQuery function to bind both touch and click events simultaneously From http://jsbin.com/ijizat/25/
function touchClick(sel, fnc) {
$(sel).live('touchstart click', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
fnc(event);
event.handled = true;
} else {
return false;
}
@raddevon
raddevon / template-tag.sublime-snippet
Created June 2, 2013 15:55
Handlebars template element tag Sublime Text snippet
<snippet>
<content><![CDATA[
<template name="$1">
$2
</template>
]]></content>
<tabTrigger>template</tabTrigger>
<description>Handlebars template name tag</description>
<scope>text.html.handlebars</scope>
</snippet>
@raddevon
raddevon / input-change-with-delay.js
Created June 7, 2013 14:33
Bind form input value change with a delay
// Bind input change with a delay
$(document).on('input propertychange', 'textarea', function () { // Change 'textarea' to desired element
var detailsElement = $(this),
details = $(this).val();
// If it's the propertychange event, make sure it's the value that changed.
if (window.event && event.type == 'propertychange' && event.propertyName != 'value')
return;
// Clear any previously set timer before setting a fresh one
window.clearTimeout($(this).data('timeout'));
@raddevon
raddevon / GAE Dev Server.sublime-build
Created June 12, 2013 14:40
Google App Engine development server build system for Sublime Text
{
"cmd": ["dev_appserver.py", "$project_path"]
}
@raddevon
raddevon / GAE Deploy.sublime-build
Created June 12, 2013 14:44
Google App Engine deployment build system for Sublime Text
{
"cmd": ["appcfg.py", "update", "$project_path"]
}
@raddevon
raddevon / gist:5815372
Created June 19, 2013 15:47
Smooth scrolling anchor links with jQuery. This script was taken from http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery . I modified it to fix a bug when using it with anchor links pointing to the top of the page ('#').
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': ($target.offset()) ? $target.offset().top : 0
}, 400, 'ease', function () { // Set the duration and easing function as desired.
window.location.hash = target;
});
});
@raddevon
raddevon / Gruntfile.js
Created June 21, 2013 15:21
Gruntfile for my personal site
var scripts = ['js/jquery-1.9.1.js', 'js/jquery.animate-enhanced.min.js','jquery.easing.min.js', 'js/**/*.js', '!js/scripts.js'];
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {