Skip to content

Instantly share code, notes, and snippets.

View ifandelse's full-sized avatar

Jim Cowart ifandelse

View GitHub Profile
@ifandelse
ifandelse / IE_Sucks.html
Created April 28, 2011 03:59
Testing Script Element Insertion with jQuery and IE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="js/jquery-1.5.2.js"></script>
<script type="text/javascript">
$(function(){
@ifandelse
ifandelse / MementoGist.cs
Created May 6, 2011 02:10
Trying to work out a way for a Memento Reset's behavior to be unknown/transparent to target domain model
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace ResetIdeas
{
class Program
@ifandelse
ifandelse / FileCombiner.cs
Created July 29, 2011 21:26
Playing with C# 'event loop' approach to demonstrate against nodejs example of same functionality
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace FileCombiner
{
class Program
@ifandelse
ifandelse / eagerload.js
Created August 15, 2011 14:26
How to use the Knockout.js-External-Template-Engine to Eager Load Templates
var tmplEagerLoad = [ "customer", "user", "search", "about", "orders" ];
// This will cause the templates to be requested and cached locally
// in script blocks for KO to pick up like any normal embedded template
tmpl.EagerLoad.forEach(function(template) {
ko.externaljQueryTemplateEngine.getTemplateNode(template);
});
@ifandelse
ifandelse / trafficCop.js
Created November 25, 2011 06:50
Traffic Cop Source
/*
TrafficCop
Author: Jim Cowart
License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license)
Version 0.1.0
*/
(function($, undefined) {
var inProgress = {};
@ifandelse
ifandelse / cartModule.js
Created January 16, 2012 03:59
Client-side Messaging in JavaScript - Part 2 (Postal.js) Example 2
var cartModule = (function(postal, $){
var cartId = 0,
cartTemplate = "#cart-tmpl",
cartItemTemplate = "#cart-item-tmpl",
cartChildrenSelector = "#cart-list",
wireUpCart = function(cart) {
postal.subscribe("cart", "init", _.bind(cart.init,cart));
postal.subscribe("cart", "item.add", function(item) {
var member = cart.id + "-" + item.id;
@ifandelse
ifandelse / deepExtend.js
Created February 20, 2012 18:47
Custom Deep Extend Mixin for Underscore
var slice = [].slice;
if (!_.deepExtend) {
var behavior = {
"*": function(obj, sourcePropKey, sourcePropVal) {
obj[sourcePropKey] = sourcePropVal;
},
"object": function(obj, sourcePropKey, sourcePropVal) {
obj[sourcePropKey] = deepExtend(obj[sourcePropKey] || {}, sourcePropVal);
},
"array": function(obj, sourcePropKey, sourcePropVal) {
@ifandelse
ifandelse / PrfTst.js
Created February 27, 2012 04:35
PrfTst
/*
postal.js
Author: Jim Cowart
License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license)
Version 0.6.0
*/
(function(root, doc, factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
@ifandelse
ifandelse / ConnectivityFsm.js
Created March 14, 2012 05:30
FSM to manage offline/online
var ConnectivityFsm = ( function( $, machina, amplify ) {
return function( heartbeatDef ) {
var settings = $.extend( true, {
type: "GET",
dataType: "json",
timeout: 5000
}, heartbeatDef );
@ifandelse
ifandelse / amplify.js
Created March 20, 2012 16:34
amplify.js in an AMD Wrapper
/*!
* AmplifyJS 1.0.0 - Core, Store, Request
*
* Copyright 2011 appendTo LLC. (http://appendto.com/team)
* Dual licensed under the MIT or GPL licenses.
* http://appendto.com/open-source-licenses
*
* http://amplifyjs.com
*/
(function(root, doc, factory) {