Skip to content

Instantly share code, notes, and snippets.

View jcreamer898's full-sized avatar
🏠
Working from home

Jonathan Creamer jcreamer898

🏠
Working from home
View GitHub Profile
@jcreamer898
jcreamer898 / gist:1591029
Created January 10, 2012 20:34
Javascript Standards and Patterns

From Javascript Web Applications by Alex MacCaw,

"The secret to making large JavaScript applications is not to make large JavaScript applications. Instead, you should decouple your application into a series of fairly independent components. The mistake developers often make is creating applications with a lot of interdepenency, with huge linear JavaScript files generating a slew of HTML tags. These sorts of applications are difficult to maintain and extend, so they should be avoided at all costs. Paying a bit of attention to an applications structure when you start building it can make a big difference to the end result. Ignore any preconceived notions you have about JavaScript and treat it like the object-oriented language that it is. Use classes, ineritance, objects, and patterns in the same way you would if you were building an application in another language such as Python or Ruby. Architecture is critical to server-side applications, so why shouldn't the same apply to client-side apps."

Our applic

@jcreamer898
jcreamer898 / gist:1870646
Created February 20, 2012 18:45
Setting up docco for Windows 7
@jcreamer898
jcreamer898 / jquery.slugify.js
Created February 23, 2012 20:10
jQuery slugify a url
;(function ($, window, document, undefined) {
// Define the jQuery plugin name and some default options
var pluginName = 'slugify',
defaults = {
on: "blur",
prefix: ''
};
// The actual plugin constructor
function Slugify(element, options) {
@jcreamer898
jcreamer898 / gist:2041033
Created March 15, 2012 01:30
NashDotNet Lab on MVC3

#MVC3

  • An architectural pattern invented in the late 70's early 80's.
  • Promotes separation of concerns and eases unit testing
  • MVC is great for web apps because of HTTP
    • HTTP requests
    • Retrieve data
    • Return views
  • It is stateless, just like HTTP
    • No postbacks and view state
@jcreamer898
jcreamer898 / gist:2413975
Created April 18, 2012 14:33
Addy Osmani's Recommended JavaScript Style Guides & Beautifiers

For developers interested in improving the code style consistency of the JavaScript they write, I'm happy to recommend the following style guides:

  1. Idiomatic.js https://github.com/rwldrn/idiomatic.js/ (highly recommended, very comprehensive and includes contributions by +Rick Waldron , +Mathias Bynens and more)

  2. jQuery Core Style Guide http://docs.jquery.com/JQuery_Core_Style_Guidelines (used by jQuery core, QUnit and many other projects)

  3. Google JavaScript Style Guide - http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml with some further comments http://blog.founddrama.net/2010/08/annotated-google-javascript-style-guide/

  4. Dojo Style Guide http://dojotoolkit.org/community/styleGuide (another very comprehensive alternative)

@jcreamer898
jcreamer898 / gist:2560294
Created April 30, 2012 17:29
Generics for Geriatrics
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
@jcreamer898
jcreamer898 / gist:2930452
Created June 14, 2012 13:55
Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.8)
chunky_png (1.2.5)
coffee-script (2.2.0)
coffee-script-source
@jcreamer898
jcreamer898 / item.html
Created June 19, 2012 13:54
Exclude a child.
<li class="selected">
<div class="item-desc">
<h2>Basic Party Pack</h2>
<p><span>$32 </span>for 2 guests</p>
<p class="per">$15.79 per guest</p>
<a title="View Details" href="#/abc1" class="selected">View Details</a>
</div>
<div class="add">
<form>
<label for="qty">Qty: <input type="text" id="qty_q0" class="qty"></label>
@jcreamer898
jcreamer898 / package.json
Created June 28, 2012 17:55
package.json file for CDNJs
{
"name": "jquery-mockjax",
"filename": "jquery.mockjax.js",
"version": "1.5.0pre",
"description": "Mockjax. The jQuery Mockjax Plugin provides a simple and extremely flexible interface for mocking or simulating ajax requests and responses.",
"url": "http://code.appendto.com/plugins/jquery-mockjax/",
"keywords": [ "ajax", "mock", "unit" ],
"author": "Jonathan Sharp (http://jdsharp.com/)",
"bugs": {
"web": "http://github.com/appendto/jquery-mockjax/issues"
@jcreamer898
jcreamer898 / index.md
Created July 13, 2012 18:28
Using reduce to build a string out of an array