Skip to content

Instantly share code, notes, and snippets.

View jessemcdowell's full-sized avatar

Jesse McDowell jessemcdowell

View GitHub Profile
@jessemcdowell
jessemcdowell / navigation.js
Created April 1, 2014 18:56
Angular Navigation
'use strict';
// var module = angular.module('...', []);
module.service('navigation', function($location) {
var storage = null;
return {
navigate: function(path, data) {
storage = {
path: path,
@jessemcdowell
jessemcdowell / gist:9920807
Created April 1, 2014 19:05
Triggering Navigation
module.controller('Page1Controller', ['$scope', 'navigation', function($scope, navigation) {
$scope.navigate = function (navigationParameter) {
navigation.navigate('/Page2', navigationParameter);
};
}]);
@jessemcdowell
jessemcdowell / gist:9920871
Created April 1, 2014 19:08
Retrieving Navigation Parameter
module.controller('Page2Controller', ['$scope', 'navigation', function ($scope, navigation) {
$scope.navigationParameter = navigation.getNavigationData();
}]);
int Average(int a, int b)
{
}
@jessemcdowell
jessemcdowell / gist:924497
Created April 17, 2011 21:30
SimpleAverage
int SimpleAverage(int a, int b)
{
return (a + b) / 2;
}
@jessemcdowell
jessemcdowell / gist:924495
Created April 17, 2011 21:28
SystemMathAverage
int SystemMathAverage(int a, int b)
{
return System.Math.Average(a, b);
}
@jessemcdowell
jessemcdowell / gist:924508
Created April 17, 2011 21:48
ConversionAverage
int ConversionAverage(int a, int b)
{
return (Int32)(((Int64)a + (Int64)b) / 2);
}
@jessemcdowell
jessemcdowell / gist:949410
Created April 30, 2011 04:29
TestAverageMethod()
void TestAverageMethod(Func<int, int, int> method)
{
string methodName = method.Method.Name;
List<string> failureText = new List<string>();
int passCount = 0;
int testCount = 0;
Action<int, int, int> test = (a, b, expected) =>
{
@jessemcdowell
jessemcdowell / gist:949422
Created April 30, 2011 04:40
LinqAverage
int LinqAverage(int a, int b)
{
int[] inputArray = new int[] { a, b };
return (int)inputArray.Average();
}
@jessemcdowell
jessemcdowell / gist:950058
Created April 30, 2011 22:43
JessesAverage
int JessesAverage(int a, int b)
{
return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
}