Wednesday, 15 October 2014

Calculating color contrast in JavaScript

image

To calculate which foreground color to use on a background we have the following function:

Taken from: http://24ways.org/2010/calculating-color-contrast/

You can use this website to confirm it meets the W3C standards:  http://snook.ca/technical/colour_contrast/colour.html

Monday, 13 October 2014

Example of DataRepository pattern

Here is a quick example of a data repository pattern used with EF. Note the UpdateEntity method in AccountRepository purely returns the entity to be updated, this perhaps should be named more clearly.

This example was taken from Miguel Castro and uses MEF as it's DI container.

Friday, 10 October 2014

Resolving within Angular routing

You can have your routing code make services or data available to your controller by using resolve.

image

This is how we expose these functions to the controller:

image

image

Tuesday, 1 July 2014

QuickGraph: Modelling the London Underground in C#

quickgraph.banner.png

In this example we model the London Underground, well more specifically the Victoria, Bakerloo and Circle lines.

We ask the question: what is the shortest path between Marylebone and Victoria?

This requires a change at Oxford Circus from the Bakerloo to Victoria line.  Thanks to QuickGraph we can easily model the London underground as a graph.

image

The way this works is that we have our TrainLine and Station classes each populated with the relevant names.  Each TrainLine has an ordered list of it’s Stations.  We then loop through each of the TrainLines and their Stations to create a graph, adding “edges” between each of the stations.  This map is then used by the library to calculate the shortest path. Source:  https://github.com/stevenh77/QuickGraphExample/

Simple Many to Many design

A linked list would be a more logical representation of stations for a train line but for this example we’re using a list.

Material Design: Google’s new design language

image

image

image

image

image

image

image

image

image

 

image

image 

image

image

image

image

image

image

image

image

image

image

For more info check out:  http://google.com/design

You can check out some examples on the Polymer website, here’s one to get you started:  http://www.polymer-project.org/apps/topeka/

12345678910111213