Skip to content

Instantly share code, notes, and snippets.

View raddevon's full-sized avatar

Devon Campbell raddevon

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / modal-focus.js
Created October 19, 2015 11:20 — forked from anonymous/modal-focus.js
Focus first text input on Bootstrap modal show
(function ($) {
var _original = $.fn.modal.Constructor.prototype.show;
function trigger(target, name, relatedTarget) {
target.trigger($.Event(name, { relatedTarget: relatedTarget }));
}
$.extend($.fn.modal.Constructor.prototype, {
show: function (_relatedTarget) {
var thisModal = this;
@raddevon
raddevon / gist:7e4dff70a200077ea922
Last active August 29, 2015 14:16
Shell script to install Vim plugins for spf13 users
function vimp() {
changed=false
for plugin
do
if grep -q "$plugin" ~/.vimrc.bundles*
then
echo "$plugin already installed"
else
echo "Adding $plugin to bundles config"
echo Bundle \"$plugin\" >> ~/.vimrc.bundles.local
@raddevon
raddevon / gulpfile.js
Created May 19, 2014 13:03
Sample gulpfile from a recent project
var gulp = require('gulp');
// Using this plugin, you won't manually have to require each plugin you add. This does the work for you.
// Just remember you'll have to prepend 'plugins' to your plugin function when you build your tasks.
var gulpLoadPlugins = require('gulp-load-plugins');
// Turn lazy loading of plugins off to make the connect plugin work
var plugins = gulpLoadPlugins({lazy: false});
// Check out the autoprefixer docs to see how to build settings for gulp-autoprefixer
// https://github.com/ai/autoprefixer
var prefixerSetting = ['last 1 versions', '> 1%'];