Skip to content

Instantly share code, notes, and snippets.

View adamwdraper's full-sized avatar

Adam Draper adamwdraper

View GitHub Profile
@adamwdraper
adamwdraper / gist:2370107
Created April 12, 2012 18:59
Javascript AMD Cookie Manager Module
define([], function () {
var CookieManager = function() {};
CookieManager.prototype.createCookie = function(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
} else {
@adamwdraper
adamwdraper / html
Created April 12, 2012 19:02
Javascript AMD Display Notification Module
<div id="notify">
<p></p>
<a class="close" href="#">x</a>
</div>
@adamwdraper
adamwdraper / html
Created May 6, 2012 17:16
Lightweight Tabs using jQuery
<div class="tabs cf">
<a class="tab active" data-type="tab1">tab1</a>
<a class="tab" data-type="tab2">tab2</a>
<a class="tab" data-type="tab3">tab3</a>
</div>
<div class="tab-panes">
<div class="tab-pane active" data-type="tab1">
tab1 info
</div>
<div class="tab-pane" data-type="tab2">
@adamwdraper
adamwdraper / less css
Created May 6, 2012 17:43
Webkit nice scrolbar
body {
&::-webkit-scrollbar {
width: 12px;
}
&::-webkit-scrollbar-thumb {
background-color: #CCC;
border-radius: 5px;
@adamwdraper
adamwdraper / gist:2866066
Created June 4, 2012 02:51
jQuery Key Code example
$(window).on('keyup', function(e) {
switch(e.keyCode) {
// space
case 32:
break;
// enter
case 13:
break;
// up arrow
case 38:
@adamwdraper
adamwdraper / gist:2951011
Last active February 11, 2024 22:23
AMD jQuery plugin template
// Uses AMD or browser globals to create a jQuery plugin.
/**
* Name - jQuery Plugin
*
* Version: 0.0.1 (5/25/2012)
* Requires: jQuery v1.7+
*
* Copyright (c) 2011 User - http://github.com/username
* Under MIT and GPL licenses:
@adamwdraper
adamwdraper / Node.js File Looper
Created December 5, 2012 04:46
Loop through all files in a given directory with node.js
var fs = require('fs');
var walkPath = './';
var walk = function (dir, done) {
fs.readdir(dir, function (error, list) {
if (error) {
return done(error);
}
@adamwdraper
adamwdraper / gist:7285783
Created November 3, 2013 02:19
Require.js Plugin to load uncompiled Handlebars templates
/**
* @appular hbs v0.0.1 - include file as text and convert it to a handlebars template
* @define hbs!
*/
// hbtemplate.js plugin for requirejs / text.js
// it loads and compiles Handlebars templates
define([
'handlebars'
], function (Handlebars) {
@adamwdraper
adamwdraper / gist:7915108
Created December 11, 2013 17:48
Adding get/set functions to backbone view to get/set options
_.extend(Backbone.View.prototype, {
// Set a hash of module options on the object, firing `"change"`.
set: function(key, value, options) {
var attribute,
attributes,
changes,
silent,
changing,
previous,
current;
@adamwdraper
adamwdraper / Gruntfile.js
Created August 19, 2014 18:24
Framer Grunt Server
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
open : {
server : {
path: 'http://localhost:5000'
}
},