Skip to content

Instantly share code, notes, and snippets.

View aaronshaf's full-sized avatar

Aaron Shafovaloff aaronshaf

View GitHub Profile
@aaronshaf
aaronshaf / gist:3796802
Created September 27, 2012 22:21
Transloadit template example - stores original file without colon in prefix
/*
This template works for both image and non-image files. Image thumbnails are given respective step-name prefixes.
Original files are stored with the "original" prefix without the standard, annoying colon.
*/
{
"steps": {
"32x32": {
"use": ":original",
"robot": "/image/resize",
$.when(
Products.recent(),
Sites.find()
).done(function(products,sites) {
res.render('products/index', {
title: 'Products',
products: products,
sites: sites
});
});
var Products = {
recent: function() {
var deferred = $.Deferred();
config.mongo.connection.collection('products',function(error, collection) {
collection.find().sort({'modified':-1}).limit(20).toArray(function(err, products) {
if(err)
deferred.fail(err);
else
deferred.resolve(products);
});
@aaronshaf
aaronshaf / gist:5462451
Last active December 16, 2015 16:19
Recursively prune key from object
var recursivePrune = function (obj,keyToRemove) {
if(typeof obj === "object" && obj instanceof Array) {
for(x = 0;x < obj.length;x++) {
obj[x] = this.recursivePrune(obj[x],keyToRemove);
}
} else if(typeof obj === "object") {
delete obj[keyToRemove];
Object.getOwnPropertyNames(obj).forEach(function(property) {
obj[property] = recursivePrune(obj[property],keyToRemove);
});
@aaronshaf
aaronshaf / getIDBSignature.js
Created May 18, 2013 13:31
Get the "signature" of an IndexedDB database. Hopefully this becomes useful to those who are trying to circumvent versioning.
function getIDBSignature(name,callback) {
var request = window.indexedDB.open(name);
request.onsuccess = function(event) {
var x,db = event.target.result;
var objectStore,objectStores = [];
for(x = 0;x < db.objectStoreNames.length;x++) {
objectStores.push(db.objectStoreNames.item(x));
}
var transaction = db.transaction(objectStores, "readonly");
objectStores = objectStores.map(function(objectStoreName) {
module.exports = function(grunt) {
grunt.initConfig({
clean: ['public/js/'],
type: {
'default': {
files: [
{
src: 'public/ts/app.ts',
dest: 'public/js/app.js'
}
@aaronshaf
aaronshaf / JavaScript.md
Last active April 11, 2022 18:01
All Things JavaScript
@aaronshaf
aaronshaf / Workflow.md
Last active December 17, 2015 23:49
Programming Workflow
@aaronshaf
aaronshaf / HolyGrail.md
Last active December 18, 2015 00:18
Holy Grail