Skip to content

Instantly share code, notes, and snippets.

View martinnormark's full-sized avatar
:shipit:
Always Be Shipping

Martin Høst Normark martinnormark

:shipit:
Always Be Shipping
View GitHub Profile
IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<GeoFeedHub>();
hubContext.Clients.All.addTweetToMap(status);
@martinnormark
martinnormark / Backbone.ChangeAwareModel.js
Created May 28, 2013 14:25
Change tracking for Backbone models
(function () {
Backbone.ChangeAwareModel = Backbone.Model.extend({
initialize: function () {
Backbone.Model.prototype.initialize.apply(this, arguments);
_.bindAll(this, "mark_to_revert", "revert");
this.attributesChanged = [];
//
// Copyright (c) 2013 Parse. All rights reserved.
#import "AppDelegate.h"
#import <Parse/Parse.h>
#import "LoginViewController.h"
#import "UserDetailsViewController.h"
@implementation AppDelegate
@martinnormark
martinnormark / oldie.html
Created April 19, 2013 09:59
Gracefully handle oldIE with jQuery 1.9.1
<!--[if lt IE 9]>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="http://code.jquery.com/jquery-2.0.0.min.js"></script>
<!--<![endif]-->
@martinnormark
martinnormark / AlertView.js
Created February 7, 2013 10:25
Twitter Bootstrap Alert view for Backbone.js
(function () {
MyApp.AlertView = Backbone.View.extend({
tagName: "div",
className: "alert fade",
template: ["<a href=\"#\" data-dismiss=\"alert\" class=\"close\">&times;</a>", "<strong>{{ title }}</strong>", "{{ message }}"].join("\n"),
@martinnormark
martinnormark / ios-log-output.log
Last active December 11, 2015 19:18
Sample iOS logging output
2013-01-27 10:11:26.113 iOS-logging-experiments[24010:c07] -[BPViewController logContextButtonPressed:]:31 someObject=(
)
2013-01-27 10:11:26.115 iOS-logging-experiments[24010:c07] -[BPViewController logContextButtonPressed:]:34 someObject=(
foo
)
2013-01-27 10:11:26.116 iOS-logging-experiments[24010:c07] -[BPViewController logContextButtonPressed:]:36 someObject=(
foo
)
2013-01-27 10:11:26.138 iOS-logging-experiments[24010:c07] (
0 iOS-logging-experiments 0x000021ee -[BPViewController logContextButtonPressed:] + 302
@martinnormark
martinnormark / HandleAjaxErrorAttribute.cs
Created January 23, 2013 09:17
Log handled exception in AJAX request to ELMAH
using System.Net;
using System.Web.Mvc;
namespace MyApp.Web.PresentationLogic.ActionFilters
{
public class HandleAjaxErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
if (!filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
@martinnormark
martinnormark / countersunk-table-rows.css
Created January 15, 2013 10:31
CSS for rendering table rows, as if they were countersunk in relation to the rows above and below
tr.countersink.top td {
-webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
-moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
}
tr.countersink td {
background-color: #F7F7F7;
-webkit-box-shadow: inset 0 0px 5px rgba(0, 0, 0, 0.125);
-moz-box-shadow: inset 0 0px 5px rgba(0, 0, 0, 0.125);
@martinnormark
martinnormark / UrlHelperExtensions.cs
Last active December 21, 2020 11:18
Adding build number to static file paths for cache busting in ASP.NET MVC
public static class UrlHelperExtensions
{
private static int _revisionNumber;
public static string ContentVersioned(this UrlHelper urlHelper, string contentPath)
{
string url = urlHelper.Content(contentPath);
int revisionNumber = GetRevisionNumber();
return String.Format("{0}?v={1}", url, revisionNumber);
@martinnormark
martinnormark / EmailAddressAttribute.cs
Created January 12, 2013 20:42
Email Address validation for ASP.NET MVC
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
using System.Web.Mvc;
namespace MyApp.Web.PresentationLogic.Validation
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class EmailAddressAttribute : DataTypeAttribute, IClientValidatable