Skip to content

Instantly share code, notes, and snippets.

// omdb
/*
angular.module('omdb', [])
.factory('omdbApi', function($http, $q) {
var service = {};
var baseUrl = 'http://www.omdbapi.com/?v=1&';
function httpPromise (url) {
//movie-core
/* angular.module('movieCore', ['ngResource'])
.factory('PopularMovies', function($resource) {
var token = 'teddybear'; // TBC
return $resource('popular/:movieId', { movieId: '@id' }, {
update: {
method: 'PUT',
headers: { 'authToken': token }
},
describe('omdb service', function() {
var movieData = {"Search":[{"Title":"Star Wars: Episode IV - A New Hope","Year":"1977","imdbID":"tt0076759","Type":"movie"},{"Title":"Star Wars: Episode V - The Empire Strikes Back","Year":"1980","imdbID":"tt0080684","Type":"movie"},{"Title":"Star Wars: Episode VI - Return of the Jedi","Year":"1983","imdbID":"tt0086190","Type":"movie"},{"Title":"Star Wars: Episode I - The Phantom Menace","Year":"1999","imdbID":"tt0120915","Type":"movie"},{"Title":"Star Wars: Episode III - Revenge of the Sith","Year":"2005","imdbID":"tt0121766","Type":"movie"},{"Title":"Star Wars: Episode II - Attack of the Clones","Year":"2002","imdbID":"tt0121765","Type":"movie"},{"Title":"Star Wars: The Clone Wars","Year":"2008","imdbID":"tt1185834","Type":"movie"},{"Title":"Star Wars: The Clone Wars","Year":"2008–2015","imdbID":"tt0458290","Type":"series"},{"Title":"Star Wars: Clone Wars","Year":"2003–2005","imdbID":"tt0361243","Type":"series"},{"Title":"The Star Wars Holiday Special","Year":"1978","i
@SamLeach
SamLeach / AuthorizeController.cs
Created November 2, 2014 21:12
AuthorizeController.cs
[Authorize]
public AuthorizeController : ApiController
{
[HttpGet]
public string Get()
{
return "Foo";
}
}
@SamLeach
SamLeach / game.js
Created October 18, 2014 16:08
Conway's Game of Life constructor
var Game = function(name){
this.name = name;
}
@SamLeach
SamLeach / SpecRunner.html
Created October 18, 2014 16:07
Conway's Game of Life Spec Runner
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Spec Runner v2.0.2</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.0.2/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.2/jasmine.css">
<script type="text/javascript" src="lib/jasmine-2.0.2/jasmine.js"></script>
@SamLeach
SamLeach / GameSpec.js
Created October 18, 2014 16:06
Conway's Game of Life Jasmine Spec
describe("The Game", function() {
var game;
beforeEach(function() {
game = new Game("Conway's");
});
it("should be Conway's Game of Life", function() {
expect(game.name).toEqual("Conway's");
});
@SamLeach
SamLeach / GuardAgainstNulls.cs
Created October 10, 2014 15:39
Guard Against Null
static class Guard
{
public static void AgainstNulls(object parameter, string name)
{
if (parameter == null)
{
throw new ArgumentNullException(name);
}
}
}
@SamLeach
SamLeach / classWithThrowIfNull.cs
Created October 10, 2014 15:34
Dummy class using ThrowIfNull extension method
public MyClass(
IDependency1 dependency1,
IDependency2 dependency2,
IDependency3 dependency3,
IDependency4 dependency4)
{
dependency1.ThrowIfNull("dependency1");
dependency2.ThrowIfNull("dependency2");
dependency3.ThrowIfNull("dependency3");
dependency4.ThrowIfNull("dependency4");
@SamLeach
SamLeach / nullArguments.cs
Created October 10, 2014 15:30
Null arguments class
public MyClass(
IDependency1 dependency1,
IDependency2 dependency2,
IDependency3 dependency3,
IDependency4 dependency4)
{
if (dependency1 == null)
{
throw new ArgumentNullException("dependency1");
}