This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write an AddOne method that doesn't use yield or foreach | |
static IEnumerable<int> AddOne(IEnumerable<int> items) | |
{ | |
var returnEnumer = Enumerable.Empty<int>(); | |
var enumerator = items.GetEnumerator(); | |
while(enumerator.MoveNext()) | |
{ | |
returnEnumer = returnEnumer.Concat(Enumerable.Repeat(enumerator.Current + 1, 1)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var timeStorage = new TimeStorage(); | |
var item = "Hello World"; | |
timeStorage.Add(item); | |
var items = timeStorage.GetItems(); | |
items.Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Force all properties bound to the price data binding to reevaluate | |
function forceBindingRefresh(bindingName, element) { | |
var bindings = $(element).data("bind"); | |
var koElement = ko.dataFor(element); | |
if (bindings.indexOf(bindingName) >= 0) { | |
// Lets split up the bindings so we can deal with each one | |
bindings = bindings.split(","); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function zero(exp) { return numberExpression(0, exp); } | |
function one(exp) { return numberExpression(1, exp); } | |
function two(exp) { return numberExpression(2, exp); } | |
function three(exp) { return numberExpression(3, exp); } | |
function four(exp) { return numberExpression(4, exp); } | |
function five(exp) { return numberExpression(5, exp); } | |
function six(exp) { return numberExpression(6, exp); } | |
function seven(exp) { return numberExpression(7, exp); } | |
function eight(exp) { return numberExpression(8, exp); } | |
function nine(exp) { return numberExpression(9, exp); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hamming (n) { | |
// TODO: Program me | |
var hammedNumbers = []; | |
var startIndex = 1; | |
while(hammedNumbers.length < n) | |
{ | |
var primeFactors = calcPrimeFactors(startIndex); | |
var largestPrime = primeFactors[primeFactors.length - 1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var moveZeros = function (arr) { | |
var zeros = []; | |
var foo = arr.filter(function(value) { | |
var isZero = value === 0; | |
if(isZero) { zeros.push(0); } | |
return value !== 0; | |
}) | |
return foo.concat(zeros); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var anarchy = function () { | |
var len = "htgnel".split("").reverse().join(""); | |
return 'I can write numbers like, ' + ["."][len] + ", " + [".","."][len] + ", " + [".",".","."][len] + "."; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function once(fn) { | |
var isUsed = false; | |
return function(){ | |
if(!isUsed) | |
{ | |
isUsed = true; | |
var arg = Array.prototype.slice.call(arguments, 0).reverse()[0]; | |
fn(arg); | |
return arg; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function once(fn) { | |
var isUsed = false; | |
return function(param){ | |
if(!isUsed) | |
{ | |
isUsed = true; | |
fn(param); | |
return param; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint devel: true */ | |
/*jslint browser: true, nomen: true */ | |
/*global jQuery, cf*/ | |
(function IIFE($, cf) { | |
"use strict"; | |
cf.FormValidation = function formValidation(formSelectors) { | |
var self = this; | |
function html5ValidationSupported() { |
OlderNewer