Skip to content

Instantly share code, notes, and snippets.

View nordyke's full-sized avatar

Aaron Nordyke nordyke

  • C2FO
  • Kansas City, MO
View GitHub Profile
@nordyke
nordyke / MultiSortCollection.js
Created December 27, 2011 15:38
Multi-sort on any number of Backbone Collection attributes. Sort happens from arguments[0] to arguments[n]
var MultiSortCollection = Backbone.Collection.extend({
/**
* Sort by supplied attributes. First param is sorted first, and
* last param is final subsort
* @param {String} sortAttributes
* @example collection.sortBy("last_name","first_name")
*/
sortBy : function(sortAttributes){
var attributes = arguments;
@nordyke
nordyke / JasmineTestsIdiomatic.js
Created December 29, 2011 17:14
Some Jasmine Tests for idiomatic.js
/*
* Writing Unit Tests to learn code or a library has been a fantastic strategy for me.
* I wrote these Jasmine Tests to enforce some of the very powerful concepts from
* https://github.com/rwldrn/idiomatic.js?utm_source=javascriptweekly&utm_medium=email.
*/
describe("JavaScript Idiomatics", function() {
describe("Coercion", function() {
it("coerces string into number", function() {
@nordyke
nordyke / ClassPattern.js
Created December 29, 2011 21:59
Some JavaScript Patterns
var Class = function(){
//private
var privateVariable = 2;
function privateFunction(){
return 5;
}
//public
return {
publicFunction1 : function(){
var global = "Global string";
function firstFunction(){
var local = "Local string";
alert(global); //alerts out 'Global string'
alert(local); //alerts out 'Local string'
}
function secondFunction(){
alert(global); //alerts out "Global string"
@nordyke
nordyke / inlineblock.css
Created July 17, 2012 01:20
display:inline-block
display:inline-block;
*display:inline;
*zoom:1;
@nordyke
nordyke / scss_includes.scss
Created December 11, 2012 00:04
Useful SASS mixins
// Inline-block trinity
@mixin inline-block{
display:inline-block;
*display:inline;
zoom:1;
}
// Hide text for background image replacement
@mixin hide-text{
overflow:hidden;