Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace MyProject
{
[TestFixture]
@stephen-james
stephen-james / iife.snippet
Last active August 29, 2015 13:56
Handy JavaScript snippets for Visual Studio
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Immediately Invoked Function Expression</Title>
<Author>Stephen James (@stephenhjames)</Author>
<Shortcut>iife</Shortcut>
<Description>Code snippet for an Immediately-Invoked Function Expression</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
/*!
* RequireJS plugin for async dependency load like JSONP and Google Maps
* @author Miller Medeiros
* @version 0.0.1 (2011/03/23)
* Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
define(function(){
function injectScript(src){
var s, t;
@stephen-james
stephen-james / web.config
Last active August 29, 2015 14:01
enable gzip compression on IIS
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="application/x-javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</dynamicTypes>
@stephen-james
stephen-james / .gitignore
Created May 27, 2014 13:29
lab-karma-require-jasmine step1 : ignore package source files
# npm packages
node_modules
@stephen-james
stephen-james / package.json
Created May 27, 2014 13:42
lab-karma-require-jasmine step 1 : creating the package.json file for the sample web app
{
"name": "lab-karma-require-jasmine",
"version": "0.0.0",
"description": "A step-by-step lab for setting up a simple JavaScript centric web app using RequireJS, Karma and Jasmine",
"main": "index.html",
"directories": {
"test": "test"
},
"dependencies": {},
"devDependencies": {},
@stephen-james
stephen-james / index.html
Created May 27, 2014 14:18
lab-karma-require-jasmine step 2 : setting up requirejs and the browser default page
<!DOCTYPE html>
<html>
<head>
<title>Lab : Karma, RequireJS, Jasmine</title>
</head>
<body>
<script src="node_modules/requirejs/require.js" data-main="src/main.js"></script>
</body>
</html>
@stephen-james
stephen-james / app.js
Last active August 29, 2015 14:01
lab-karam-require-jasmine step 3 - setting up the requireJS bootstrap and app entry point
define(["jquery"], function ($) {
"use strict";
var App = function (target) {
this.target = target || $("body");
};
App.prototype.start = function () {
this.target.html("App Started!");
};
@stephen-james
stephen-james / karma.conf.js
Created May 27, 2014 15:18
lab-karma-require-jasmine step 4 : getting some karma
// Karma configuration
// Generated on Tue May 27 2014 16:04:16 GMT+0100 (GMT Daylight Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
@stephen-james
stephen-james / test-main.js
Last active August 29, 2015 14:01
lab-karma-require-jasmine step 4: getting some karma, modifications to requirejs bootstrap
var allTestFiles = [];
var TEST_REGEXP = /(spec|test)\.js$/i;
var pathToModule = function(path) {
var returnValue = path.replace(/^\/base\//, '').replace(/\.js$/, '');
return returnValue;
};
Object.keys(window.__karma__.files).forEach(function(file) {
if (TEST_REGEXP.test(file)) {