Skip to content

Instantly share code, notes, and snippets.

@puleos
puleos / gist:5620456
Last active December 17, 2015 13:49
Web Application Exercise
var App = new Marionette.Application();
App.addRegions({
"content": "#content",
"navigation": "#navigation",
});
App.on("initialize:after", function() {
Backbone.history.start();
});
@puleos
puleos / gist:4319480
Created December 17, 2012 16:11
Node Manipulation using D3
// Ben Bederson
// June 2012
// www.cs.umd.edu/~bederson
$(function() {
var svg_w = 550,
svg_h = 400,
node_w = 70,
node_h = 20,
node_active_h = 50,
@puleos
puleos / servicestack redis
Created November 17, 2012 00:46
Service Stack Service Implementation w/ Redis Caching
using System;
using NBTY.Core.DTO.Puritan;
using ServiceStack.CacheAccess;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.ServiceModel;
namespace Puritan.Web.Services.Catalog.ServiceStack
{
[RestService("/category/{LegacyId}")]
@puleos
puleos / shopcart.specs
Created November 17, 2012 00:39
Sample MSpec + Moq Unit Tests
using System;
using System.Collections.Generic;
using Machine.Specifications;
using Moq;
using NBTY.Core.DTO.Puritan;
using NBTY.Core.Enums;
using Puritan.Web.Services.Catalog;
using Puritan.Web.Services.Marketing;
using Puritan.Web.Services.Session;
using Puritan.Web.Services.ShoppingCart;
@puleos
puleos / gist:3743726
Created September 18, 2012 15:21
Mooveweb redirect
'************ Moovweb Mobile Redirect -BEGIN***********
Dim endOfProtocol, endofDomain, currentPath
endOfProtocol = InStr(Request.ServerVariables("CACHE_URL"),"//")
endOfHost = InStr(endOfProtocol + 2, Request.ServerVariables("CACHE_URL"),"/")
currentPath = Mid(Request.ServerVariables("CACHE_URL"), endOfHost)
@puleos
puleos / gist:3171059
Created July 24, 2012 16:32
PP Upsell Template
<script id="upsellTemplate" type="text/x-jquery-tmpl">
<li class="upsell-container">
<table border="1" width="250" height="440" >
<tr><td>
<p id="item-image">
<a href="${productUrl}" title="${name.replace("�", "™")}"><img src="${productImage}" alt="${name.replace("�", "™")}" /></a></p>
{{if reviewStars > 0}}
<p><img src="${reviewUrl}" /><a href="${productUrl}" class="blue">${parseInt(reviewStars)} Reviews </a> </p>
{{else}}
<p><img src="http://images.vitaminimages.com/pp/images/ratings_0.jpg" /> <a href="${productUrl}" class="blue" >Write the first review </a></p>
@puleos
puleos / JS
Created July 24, 2012 16:31
PP IO Implementation
/* Product Detail Right Gutter */
function PD_RIGHT_zp(a, b, c, d, e, f, g, h, i, j) {
var builder = new ZoneBuilder();
var template = "upsellNarrowTemplate";
var divTarget = "upsell-right";
var categoryId = '5001';
var upsellCount = 12;
if (showNewProductWebsite === "true") {
template = "upsellNarrowTemplate2";
@puleos
puleos / jslint.json
Created April 15, 2012 23:17
sublime text jslint settings
{
// Path to the jslint jar.
// Leave blank to use bundled jar.
"jslint_jar": "",
// Options pass to jslint.
"jslint_options": "--node --browser --white --sloppy --nomen --undef --unparam --vars",
// Ignore errors, regex.
"ignore_errors":
public static IQueryable<TEntity> WhereIn<TEntity, TValue>
(
this ObjectQuery<TEntity> query,
Expression<Func<TEntity, TValue>> selector,
IEnumerable<TValue> collection
)
{
if (selector == null) throw new ArgumentNullException("selector");
if (collection == null) throw new ArgumentNullException("collection");
ParameterExpression p = selector.Parameters.Single();
@puleos
puleos / JSON-TSQL.sql
Created March 18, 2011 23:22
Json Parse Functions for MS SQL (by Phil Factor)
IF OBJECT_ID (N'dbo.parseJSON') IS NOT NULL
DROP FUNCTION dbo.parseJSON
GO
CREATE FUNCTION dbo.parseJSON( @JSON NVARCHAR(MAX))
RETURNS @hierarchy TABLE
(
element_id INT IDENTITY(1, 1) NOT NULL, /* internal surrogate primary key gives the order of parsing and the list order */
parent_ID INT,/* if the element has a parent then it is in this column. The document is the ultimate parent, so you can get the structure from recursing from the document */
Object_ID INT,/* each list or object has an object id. This ties all elements to a parent. Lists are treated as objects here */