Skip to content

Instantly share code, notes, and snippets.

View couellet's full-sized avatar

Charles Ouellet couellet

View GitHub Profile
var copyAttribute = function (attr, source, target, altAttr) {
if (!!altAttr && !!source.data(altAttr)) {
target.data(attr, source.data(altAttr));
}
else {
target.data(attr, source.data(attr));
}
};
var setSnipAttributes = function (item) {
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using RestSharp;
using RestSharp.Authenticators;
/*
You will need to install these two NuGet packages:
Install-Package RestSharp
Install-Package Newtonsoft.Json
@couellet
couellet / gist:5864798
Last active December 18, 2015 23:49
Generate links with AttributeRouting for WebApi
public class OrdersController : ApiController
{
// RouteName parameter is mandatory to generate URLs.
[GET("api/orders/{orderId}/items", RouteName = "GetOrderItems")]
public HttpResponseMessage GetOrderItems(int orderId)
{
var myUrl = Url.Link("GetOrderItems", new { orderId = orderId });
return Request.CreateResponse(HttpStatusCode.OK);
}
public abstract class Entity
{
public int Id {get;set;}
}
public class EntityFrameworkSession : ISession
{
private readonly DbContext context;
public EntityFrameworkSession(DbContext context)