Skip to content

Instantly share code, notes, and snippets.

View markcoleman's full-sized avatar

Mark Coleman markcoleman

View GitHub Profile
@markcoleman
markcoleman / gist:5300596
Created April 3, 2013 11:59
Revised scroll directive that supports IE8 Offset from http://stackoverflow.com/a/10286208/181776 Scroll from http://stackoverflow.com/a/14880862/181776
.directive("scroll", function ($window) {
return function (scope, element, attrs) {
function getScrollOffsets(w) {
// Use the specified window or the current window if no argument
w = w || window;
// This works for all browsers except IE versions 8 and before
if (w.pageXOffset != null) return {
@markcoleman
markcoleman / gist:5271369
Created March 29, 2013 14:59
Why all your text in BootStrap is black when printing?
@media print {
* {
color: #000 !important;
text-shadow: none !important;
background: transparent !important;
box-shadow: none !important;
}
@markcoleman
markcoleman / gist:5093740
Created March 5, 2013 20:01
AngularJs with no $ sign in the currency
{{destination.payoffAmount | currency:''}}
@markcoleman
markcoleman / gist:5085650
Created March 4, 2013 21:05
Modified toJson method for AngularJs so Json.Net remains happy
$httpProvider.defaults.transformRequest = function (data) {
function isWindow(obj) {
return obj && obj.document && obj.location && obj.alert && obj.setInterval;
}
function isScope(obj) {
return obj && obj.$evalAsync && obj.$watch;
}
function isFile(obj) {
return toString.apply(obj) === '[object File]';
}
@markcoleman
markcoleman / currency wrapper
Created February 26, 2013 21:00
Simple AngularJs directive that adds a positive and negative class to the element, using the built in currency filter
angular.module('homeBanking.directives', [])
.directive("hbCurrency", ($filter: ng.IFilterService) => {
return {
restrict: "EAC",
require: "?$filter",
link: function ($scope: ng.IScope, elm, attrs) {
var currencyFilter = $filter('currency'),
rawAmount = $scope.$eval(attrs.hbCurrency),
className = rawAmount >= 0 ? "positive" : "negative";
@markcoleman
markcoleman / gist:4627686
Created January 24, 2013 21:01
Fix for our CI server when using NancyFX Testing
public class TestableBootstrapper : ConfigurableBootstrapper
{
public TestableBootstrapper(Action<ConfigurableBoostrapperConfigurator> action): base(action)
{
}
protected override byte[] FavIcon
{
get
@markcoleman
markcoleman / config is not needed thanks @Grumpydev
Last active December 10, 2015 21:28
NancyFX Bootstrapper with Unity and Json.Net Json.Net is also configure with CamelCaseProperyNameContractResolver()
public class Bootstrapper : UnityNancyBootstrapper
{
protected override void RegisterTypes(IUnityContainer container, IEnumerable<TypeRegistration> typeRegistrations)
{
base.RegisterTypes(container, typeRegistrations);
container.RegisterInstance(
JsonSerializer.Create(new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}));
@markcoleman
markcoleman / robot.js
Created December 6, 2012 14:22 — forked from bchoii/robot.js
First Try
var Robot = function(robot) {
//\ robot.clone();
// this.mode = 'scanning';
};
var mode = 'scanning';
var targetVector = 0;
var lastFired = 0;
var iteration = 0;
@markcoleman
markcoleman / robot.js
Created December 6, 2012 14:22 — forked from bchoii/robot.js
First Try
var Robot = function(robot) {
//\ robot.clone();
// this.mode = 'scanning';
};
var mode = 'scanning';
var targetVector = 0;
var lastFired = 0;
var iteration = 0;
@markcoleman
markcoleman / robot.js
Created December 6, 2012 14:22 — forked from bchoii/robot.js
First Try
var Robot = function(robot) {
//\ robot.clone();
// this.mode = 'scanning';
};
var mode = 'scanning';
var targetVector = 0;
var lastFired = 0;
var iteration = 0;