Skip to content

Instantly share code, notes, and snippets.

View adamwdraper's full-sized avatar

Adam Draper adamwdraper

View GitHub Profile
@adamwdraper
adamwdraper / build src numeral.js
Created December 8, 2016 17:40
babel-plugin-transform-es2015-modules-umd
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['exports'], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
@adamwdraper
adamwdraper / .js
Created May 13, 2016 22:46
String replace by map
var expandEntityResult = function(data, map) {
var replacer = function(match, p1, offset, value) {
return map[p1];
};
var replace = function(value) {
var keys = Object.keys(map).join('|');
var regexp = new RegExp('^(' + keys + ')\:');
return value.replace(regexp, replacer);
};
@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'
}
},
@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 / 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 / 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: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 / 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 / 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 / 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">