Skip to content

Instantly share code, notes, and snippets.

@elisechant
elisechant / footer.html
Created February 14, 2014 00:39
CDN jQuery includes
@elisechant
elisechant / app.share.js
Last active August 29, 2015 13:56
Social share
var B_CBA = B_CBA || {};
(function ($) {
"use strict";
var $w = $(window),
BU = B_CBA.Util
;
@elisechant
elisechant / index.php
Created February 14, 2014 04:50
Native php templating
// equivalent
<?= "hello {$world}" ?>
<?= 'hello' . $world ?>
<?php echo 'hello ' . $world ?>
@elisechant
elisechant / cachedGetScript.js
Last active August 29, 2015 13:56
$.cachedGetScript Using jQuery Deferreds.
// http://msdn.microsoft.com/en-us/magazine/gg723713.aspx
var store.cachedScriptPromises = {};
$.cachedGetScript = function(url, callback) {
if (!store.cachedScriptPromises[url]) {
store.cachedScriptPromises[url] = $.Deferred(function(d) {
$.getScript(url).then(d.resolve, d.reject);
}).promise();
}
@elisechant
elisechant / index.html
Last active August 29, 2015 13:56
Ajax Progess Loader with Deferreds
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>
<body>
Loading <output id="output">0%</output>
@elisechant
elisechant / config.js
Last active August 29, 2015 14:01
Real JavaScript constants
var config = function() {
/**
* Set a debug flag
* @type {boolean}
*/
var DEBUG = true;
/**
* Set the environment variable
@elisechant
elisechant / styles.scss
Created June 4, 2014 22:14
Sass Theme partials
@import "partials/ads";
html.dark { @include dark-theme; }
html.light { @include light-theme; }
@elisechant
elisechant / application.js
Last active August 29, 2015 14:02
Ember data - exploration in mult-dimensional model relationships. Also read this: http://emberjs.com/blog/2014/03/18/the-road-to-ember-data-1-0.html and this http://www.toptal.com/emberjs/a-thorough-guide-to-ember-data. Things to remember: don't think of client data modelling as 1:1 with database tables, so read this too http://discuss.emberjs.c…
/**
* Application code which demonstrates how to define multi-dimensional
* Ember-data relationships.
*
* The example uses the following Model concepts:
* - Issue (representing an Issue)
* - User (representing a User)
* - Vote (representing a User's vote for an Issue; a Pivot Model for
* Issue and User )
*
@elisechant
elisechant / user_decorator.js
Last active August 29, 2015 14:03
Ember Model decorator for decoupling computed properties
var UserDecorator = Ember.ObjectProxy.extend({
fullName: function() {
return [this.get('firstName'), this.get('lastName')].join(' ');
}.property('firstName', 'lastName')
});
@elisechant
elisechant / nested-each-dont-work.scss
Created August 1, 2014 10:26
Nested each don't work :(
// File types available
$file-types: (
pdf: ('pdf'),
doc: ('doc docx'),
xls: ('xls xlsx'),
ppt: ('ppt pptx'),
zip: ('zip'),
img: ('jpg jpeg gif png'),
txt: ('txt default')
);