Skip to content

Instantly share code, notes, and snippets.

View JamieDixon's full-sized avatar

Jamie Dixon JamieDixon

View GitHub Profile
@JamieDixon
JamieDixon / TheBlob
Created May 20, 2014 14:22
What happens when we replace a basic mock with its real implementation
var theBlobMock = new Mock<ITheBlob>();
VS
var theBlob = new TheBlob(
new SCP(new S(), new AP(new SP(new S(), new AL(new S()))), new SCS()),
new S(),
new CP(new S()),
new MP(new S()),
new AP(new SP(new S(), new AL(new S()))),
@JamieDixon
JamieDixon / gist:6cf0cdf1dcdf3aa62909
Created June 18, 2014 15:54
Custrom Binder for Module
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
var moduleName = bindingContext.ValueProvider.GetValue(bindingContext.ModelName + ".ModuleName");
var moduleTypes = new Dictionary<string, Type>
{
{ "SearchDetails", typeof(SearchDetailsProfileModule) },
{ "SubscriptionType", typeof(SelectedSubscriptionsProfileModule) },
{ "PausePeriod", typeof(PausePeriodProfileModule) },
{ "UserProfile", typeof(UserDetailsProfileModule)}
window.pubSub = window.pubSub || {};
(function IFEE(pubSub) {
'use strict';
var eventStore = {}, lastId = 0;
pubSub.subscribe = function sub(topic, func) {
if (!eventStore.hasOwnProperty(topic)) {
eventStore[topic] = {}; // Was using an array but this seems better for unsub perf.
model.Countries =
(profile.Countries.GroupBy(
x => x.ContinentName,
y => y,
(key, g) =>
new
{
Key = key,
Value =
g.Select(
@JamieDixon
JamieDixon / Gamepad events
Created July 31, 2014 08:35
Gamepad event disptach
// Accessing gamepads in the browser is a case of obtaining an array of gamepad "snapshots"
// in an event loop
function gamepads()
{
var allGamepads = navigator.getGamepads();
requestAnimationFrame(gamepads);
}
// Each time we get the gamepads collection we need to check each gamepad and each button to see if anything has changed
@JamieDixon
JamieDixon / gist:ed2bb402419014053a77
Created August 7, 2014 07:51
Using SCSS parent selector with before and after pseudo-elements & the extend function
#bigFoo {
color: #f00;
.fooStuffs {
content: "";
display: block;
position: absolute;
top: 0;
min-height: 100%;
.taskEmotion ul li
{
&:nth-of-type(1) { @include question-pages-sprite(sadface-current); }
&:nth-of-type(2) { @include question-pages-sprite(alrightface-current); }
&:nth-of-type(3) { @include question-pages-sprite(okface-current); }
&:nth-of-type(4) { @include question-pages-sprite(happyface-current); }
&:nth-of-type(5) { @include question-pages-sprite(brilliantface-current); }
}
@include respond-to(tablet)
.taskEmotion ul li
{
&:nth-of-type(1) { @include question-pages-sprite(sadface-current); }
&:nth-of-type(2) { @include question-pages-sprite(alrightface-current); }
&:nth-of-type(3) { @include question-pages-sprite(okface-current); }
&:nth-of-type(4) { @include question-pages-sprite(happyface-current); }
&:nth-of-type(5) { @include question-pages-sprite(brilliantface-current); }
}
@media screen and (min-width: 640px) {
@JamieDixon
JamieDixon / gist:28e14f55d19235332990
Created September 12, 2014 18:03
Get rid of function wrapper
$(".next").on("click", function (evt) {
this.next.call(evt.target, evt);
}.bind(this));
@JamieDixon
JamieDixon / fontell-svg
Created November 3, 2014 11:10
SVG file failing on Fontello
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_svg "http://www.w3.org/2000/svg">
<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg version="1.1" id="Layer_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="17.553" height="14.978"
viewBox="-1.269 -0.006 17.553 14.978" overflow="visible" enable-background="new -1.269 -0.006 17.553 14.978"
xml:space="preserve">
<circle fill="none" stroke="#FF6666" stroke-width="2" cx="7.5" cy="7.5" r="6.25"/>