Skip to content

Instantly share code, notes, and snippets.

View enyo's full-sized avatar
🙌
Primarily working on Pausly

Matias Meno enyo

🙌
Primarily working on Pausly
View GitHub Profile
Shop.jsonProducts = [{"_id":"50145602d71fe6bdb0000003","descriptionHtml":"","descriptionSource":null,"name":"",ect....]
Shop.store.loadMany Shop.Product, Shop.jsonProducts
@enyo
enyo / app.js
Created December 18, 2012 12:42
var myCoolFunc = require("my-mod");
myCoolFunc("yeah");
{
"name": "boot",
"description": "Lisa's website",
"version": "0.0.1",
"private": true,
"dependencies": {
"enyo/opentip": "*",
"enyo/dropzone": "*"
},
"scripts": [
App.Router = Ember.Router.extend
enableLogging: yes
showFinancialTransfers: Ember.State.transitionTo "finances"
App.Router.map (match) ->
match("/").to "finances"
match("/finances").to "finances", (match) ->
match("/").to "listFinancialEvents"
match("/:financial_event_id").to "financialEvent"
@enyo
enyo / storefile.js
Last active December 10, 2015 22:29
var path = require("path");
exports.media = function(req, res, next) {
var file = req.files.media_upload;
// code to handle file here:
// file should already be in the right location
// The path, this file has been saved at should be:
file.path;
// To get only the filename of this path:
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

This script polyfills addEventListener, removeEventListener, and dispatchEvent. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers a single event listener on a single target.

@enyo
enyo / gist:4726916
Created February 6, 2013 23:37
Tweek dropzone to use another container for file previews
Dropzone.myDropzone.options = {
addedfile: function(file) {
file.previewTemplate = $(this.options.previewTemplate);
this.element.find(".previews").append(file.previewTemplate);
file.previewTemplate.find(".filename span").text(file.name);
file.previewTemplate.find(".details").append($("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
}
};
@enyo
enyo / preloader.js
Last active March 15, 2024 13:42
Preloading images with jQuery
/**
* Preloads the image, and invokes the callback as soon
* as the image is loaded.
*/
var preload = function(src, callback) {
// Create a temporary image.
var img = new Image();
// Invoke the callback as soon as the image is loaded
// Has to be set **before** the .src attribute. Otherwise