This file contains hidden or 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
Math.sin = (function(){ | |
var original_sin = Math.sin; | |
var cache = {}; | |
return function(n){ | |
if(cache[n] == null){ | |
cache[n] = original_sin(n); | |
console.log('adding sin of ' + n.toString() + ' to cache'); | |
} else { | |
console.log('sin cache hit: ' + n.toString()); | |
} |
This file contains hidden or 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 logCar = function(){ | |
var inp = arguments[0]; | |
return function(){ | |
console.log("I'm a " + inp.color + ' ' + inp.make); | |
}; | |
}; | |
var Car = function(make,color){ | |
this.make = make; |
This file contains hidden or 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 countdown = function(){ | |
var index = 10; | |
var log = function(){console.log(index)}; | |
var iterate = function(){ | |
log(); | |
if(index>1) setTimeout(iterate, 1000); | |
index--; | |
} | |
if(index>1){ | |
iterate(); |
This file contains hidden or 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 isCreditCard( CC ) { | |
if (CC.length > 19) | |
return (false); | |
sum = 0; multiplier = 1; l = CC.length; | |
for (i = 0; i < l; i++) | |
{ | |
digit_to_process = getCharAtIndexFromEndOfString(CC,i); | |
tmp_product = parseInt(digit_to_process) * multiplier; |
This file contains hidden or 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
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
This file contains hidden or 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
using System; | |
using System.Linq; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace Jason.Tests { | |
[TestClass] | |
public class TryParseTests { | |
[TestMethod] | |
public void TestTryParse_Func_Bad() { | |
Assert.AreEqual(0, "s".TryParse(Failover<int>)); |