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
@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 / 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]-->
//
// Copyright (c) 2013 Parse. All rights reserved.
#import "AppDelegate.h"
#import <Parse/Parse.h>
#import "LoginViewController.h"
#import "UserDetailsViewController.h"
@implementation AppDelegate
@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 = [];
IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<GeoFeedHub>();
hubContext.Clients.All.addTweetToMap(status);
@martinnormark
martinnormark / google-search-suggestion-results.xml
Last active December 24, 2015 01:50
Using the Google Search Suggestions API from C#
<toplevel>
<CompleteSuggestion>
<suggestion data="mountain bikes"/>
</CompleteSuggestion>
<CompleteSuggestion>
<suggestion data="mountain bike parts"/>
</CompleteSuggestion>
<CompleteSuggestion>
<suggestion data="mountain bike sizing"/>
</CompleteSuggestion>
@martinnormark
martinnormark / SearchSuggestionsAPI.cs
Created September 27, 2013 10:39
Simple C# API Client for the Google Search Suggestions API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ConsoleApplication1
{
public class SearchSuggestionsAPI
@martinnormark
martinnormark / predicate.cs
Created October 2, 2013 08:50
LLBLGen predicates
(CustomerFields.City.IsNotNull().And(CustomerFields.Country == "Denmark"))
@martinnormark
martinnormark / rename_replace.ps1
Created February 4, 2014 18:46
Rename file names and replace within multiple files using Powershell
ls *.* -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "SEARCH", "REPLACEMENT" } | sc $f.PSPath }
Get-ChildItem *.* -rec | Rename-Item -NewName { $_.Name -replace 'SEARCH','REPLACEMENT' }
@martinnormark
martinnormark / MailgunUploadController.cs
Last active October 5, 2017 22:17
Receive e-mails from Mailgun routes in ASP.NET MVC
using System;
using System.IO;
using System.Web;
using System.Web.Mvc;
namespace WebApp
{
public class MailgunUploadController : Controller
{
//