Skip to content

Instantly share code, notes, and snippets.

@calledT
calledT / gist:82537ed46ea355c98b27
Created August 31, 2015 01:51
Gulp group task
var groups = ['basic', 'green', 'light', 'dark'];
groups.forEach(function (group) {
gulp.task('sprites-' + group, function () {
gulp.src('./src/' + group + '/png/*.png')
.pipe(tasks.spritesmith({
imgName: 'sprite' + group + '.png',
styleName: 'sprite' + group + '.css',
imgPath: '../img/sprite' + group + '.png'
}))
.pipe(gulpif('*.png', gulp.dest('./dist/img/')))
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
/**
* jquery plugin template
* @authors Kimi (huanggengtao@gmail.com)
* @date 2014-10-15 09:54:42
* @version 0.0.1
*/
;(function($){
var Plugin = function( elem, options ) {
this.elem = elem;
@calledT
calledT / xhr.js
Created April 7, 2014 04:25
javascript XMLHttpRequest
function createXHR() {
if(typeof XMLHttpRequest != undefined) {
return new XMLHttpRequest();
}else if(typeof ActiveXObject != undefined) {
if(typeof arguments.callee.activeXString != 'string') {
var versions = ['MSXML2.XMLHttp.6.0', 'MSXML2.XMLHttp.3.0', 'MSXML2.XMLHttp'],
i, len;
for(i = 0, len = versions.length; i < len; i++ ) {
try {
new ActiveXObject(versions[i]);