Skip to content

Instantly share code, notes, and snippets.

View justinbmeyer's full-sized avatar

Justin Meyer justinbmeyer

View GitHub Profile
@justinbmeyer
justinbmeyer / newmvc.md
Created December 5, 2011 05:46
What's new in JavaScriptMVC Lately

The following is a quick overview of what's going on with JMVC since 3.0:

Deferreds

$.Model and $.View both support deferreds. Allowing super sexy code like:

$('#recipes').html('recipes.tmpl', Recipe.findAll() );
@justinbmeyer
justinbmeyer / recipejs.md
Created December 13, 2011 02:42
RecipeJS

Class

Classes are used to simplify JavaScript constructor creation. Both $.Controller and $.Model extend $.Class.

$.Class $.Class([name,] [classProperties,] [prototypeProperties])

To create a Class class of your own, call $.Class.extend with the:

  • name of the class which can be used for introspection,
  • classProperties that are attached directly to the constructor, and
@justinbmeyer
justinbmeyer / gist:1601981
Created January 12, 2012 17:39
You need a client-side dependency management and build system.

You need a client-side dependency management and build system. What I mean by this is:

A client-side script loader that does dependency management and can package your scripts for rapid download.

There are only 2 that I'm aware of that qualify are RequireJS and StealJS. There are 3 reason to use these systems:

  • Easy, Parallel, Isolated Development
  • Integrated Build Systems
  • They work on every system
@justinbmeyer
justinbmeyer / my$.js
Created February 16, 2012 13:15
my$ for Cap
(function(){
var my$ = function(selector){
if(!(this instanceof my$)){
return new my$(selector);
}
if(typeof selector === 'string'){
var arrayOfElements = my$.makeArray( document.querySelectorAll(selector) );
@justinbmeyer
justinbmeyer / Rapid Start.js
Created February 17, 2012 13:32
Rapid Start
steal('jquery/model',
'jquery/dom/fixture',
'jquery/view/ejs',
'jquery/controller/route',function(){
$.fixture("GET /services/todos.json", function(){
return [200,"success",[
{id: 1,
name: "wake up"},
@justinbmeyer
justinbmeyer / fixture.js
Created February 17, 2012 13:43
fixture
$.fixture("/searchresults", function(options){
var countries = [{
id: 1,
name : "Apple"
}]
if(!options.data.q){
return [countries];
}
@justinbmeyer
justinbmeyer / paginate.js
Created February 21, 2012 07:11
paginator example
steal('jquery/controller', 'jquery/model', function() {
$.Model("Paginator", {
defaults: {
limit: 100,
offset: 0,
count: Infinity
}
}, {
@justinbmeyer
justinbmeyer / enum.md
Created March 28, 2012 19:14
Enums in JavaScript

Reasons to Use Enums:

  1. Easier to Debug / more likely to give errors.
  2. Can look up available properties.
  3. Property values changes.

Lets break each of these down:

Easier to debug / more likely to give errors

@justinbmeyer
justinbmeyer / fastfix.js
Created April 13, 2012 14:17
Makes jQuery.event.fix fast
(function(){
var set = function(obj, prop, val){
Object.defineProperty(obj,prop,{
value : val
})
return val;
};
@justinbmeyer
justinbmeyer / requireideal.md
Created May 10, 2012 05:06
require-ideal-js

There's so many things wrong with the world of script loading today. I want an easy way to:

  • install locally scripts and their dependencies
  • load these scripts from my application

I want it to:

  • work readily with almost all existing projects, source that does not use the script loader
  • handle versioning
  • have as few configs as possible