Skip to content

Instantly share code, notes, and snippets.

TestCase("AjaxTest", sinon.testCase({
testDefferredJSONResponse: function () {
var target = this;
this.server.respondWith(
"POST", /post.*/,
[200, { "Content-Type": "application/json" },
'{ "Exception":"", "Success":true, "ValidationResult":"" }']);
$.post(
libs/jquery-1.7.2.min.js
libs/kendo.web.min.js
libs/kendo.culture.nb-NO.min.js
@pavsaund
pavsaund / forseti.yaml
Created May 1, 2012 19:38
Examlpe of pre-defined dependency configuration for forseti
Dependencies:
- Scripts/globalDependency.js
Harnesses:
- Harness:
Framework : Jasmine
Name : Jasmine Specs
SystemsSearchPath : Jasmine/Scripts/{system}.js
DescriptionsSearchPath : Jasmine/Specs/for_{system}/{description}.js
Dependencies:
@pavsaund
pavsaund / when_testing_a_certain_part_of_my_system.js
Created May 8, 2012 09:04
Jasmine Spec with sinon.test() and restoring stub before all cases are complete.
//Jasmine 1.1.0
//Sinon 1.3.4
describe("when testing a certain part of my system", sinon.test(function () {
//Arrange
var system = methodToGetSystem;
var stubbedMethod = this.stub(system, "methodName");
//Act
@pavsaund
pavsaund / pseudocode.js
Created June 15, 2012 18:43
Pseudo code for custom binder that mimics radio / check behaviour with label for
ko.bindingHandlers.yourBindingName = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
var elementId = $(element).attr("id");
//Generate custom random id, if element has none
$("<label/>").attr("for", elementId)
// insert label into dom,
// hide element
// attach click handler to label
},
@pavsaund
pavsaund / packages.KomplettDev.config
Last active December 4, 2017 04:54
chocolatey installation file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<!--DEV TOOLS-->
<package id="visualstudio2013ultimate"
installArguments="/Features:'SQL WebTools' /ProductKey:AB1CD-EF2GH-IJ3KL-MN4OP-QR5ST" />
<package id="git" />
<package id="nodejs"/>
<package id="ruby"/>
<package id="dotnet4.5"/>
<package id="scriptcs"/>
@pavsaund
pavsaund / documentation.cs
Last active February 10, 2016 21:57
Smelly code-comment examples
// This function builds the order document, validates it, stores it in the DB
// before placing an order in the ERP system. Then it stores a normalized order
// to the customers order history page.
public Order PlaceOrder() { ... }

Keybase proof

I hereby claim:

  • I am pavsaund on github.
  • I am pavsaund (https://keybase.io/pavsaund) on keybase.
  • I have a public key ASBeNFUc68jSKjyUW6BYZUed8Qqq7QKmFIVguSKWofrYBwo

To claim this, I am signing this object:

@pavsaund
pavsaund / ShoppingCart.Decorator.cs
Last active October 19, 2016 11:16
Capturing Intent with code
public class ShoppingCartWithCustomerTraceLogging : ShoppingCart
{
public override void AddCartItem(CartItem item)
{
base.AddCartItem(item);
Track(CustomerAction.CartItemAddedToCart);
}
void Track(Action action)
{
public class ShoppingCartWithCustomerTraceLogging : ShoppingCart
{
/// <summary>
/// Preferred way to add item to a customers shopping cart
/// Will add the needed extra logging required.
/// </summary>
/// <param name="item"> A CartItem that contains the qty, sku, and item price and item total price</param>
public override void AddCartItem(CartItem item)
{
base.AddCartItem(item);