This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"books": [ | |
{ | |
"isbn": "9781593275846", | |
"title": "Eloquent JavaScript, Second Edition", | |
"subtitle": "A Modern Introduction to Programming", | |
"author": "Marijn Haverbeke", | |
"published": "2014-12-14T00:00:00.000Z", | |
"publisher": "No Starch Press", | |
"pages": 472, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use latest'; | |
import stripe from 'stripe'; | |
module.exports = function(ctx,cb) { | |
var STRIPE_SECRET_KEY = ctx.secrets.STRIPE_SECRET_KEY; | |
stripe(STRIPE_SECRET_KEY).charges.create({ | |
amount: ctx.data.amount, | |
currency: ctx.data.currency, | |
source: ctx.body.stripeToken, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cj write template | |
{ | |
"template" : { | |
"data" : [ | |
{"name" : "qwe", "value" : ""}, | |
{"name" : "rty", "type" : "part"} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace IssueDOM | |
{ | |
public class Issue | |
{ | |
public string Title { get; set; } | |
public string Description { get; set; } | |
public string State { get; set; } | |
//another option instead of generic link / rel is to just model them into the domain, for example for people you could |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//generic formatter which takes in a model and transforms it to something specific for the media type | |
//StrategyFormatter is a generic formatter that you derive from to create specific ones. You override the formatter methods to write the response. | |
public interface IFormatterStrategy<TOutput> { | |
TOutput Transform(object model); | |
} | |
//loops through all the formatter strategies and asks them to handle the model | |
public abstract class StrategyFormatter<TOutput> : MediaTypeFormatter { | |
public IEnumerable<IStrategyFormatter<TOutput>> Strategies {public get;private set;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderLinkService : IOrderLinkService, ILinkService<Order> { | |
public ILinkable<Order> AddLinks(Order order) { | |
var linkedOrder = new Linkable<Order>(); | |
if (order.State == OrderStates.Created) { | |
linkedOrder.Links.Add(OrderLinks.Approval, GetApprovalUri(order.ID)); | |
} | |
//other state logic here | |
return linkedOrder; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http = require 'http' | |
server = http.createServer (req, res) -> | |
res.writeHead 200, {'Content-Type': 'text/plain'} | |
res.end 'Hello World' | |
server.listen 1337, "127.0.0.1" | |
console.log 'Server running at http://127.0.0.1:1337/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Practices.Composite.Presentation.Events; | |
using Microsoft.Practices.Composite.Regions; | |
using Microsoft.Practices.Unity; | |
namespace SomeNamespace | |
{ | |
public class SomeViewModel | |
{ | |
private readonly IUnityContainer _container; | |
private readonly IEventAggregator _eventAggregator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private TPart ComposePartWith<TPart, TImport>(TImport import) | |
{ | |
var catalog = new TypeCatalog(typeof(TPart)); | |
var childContainer = new CompositionContainer(catalog, Container); | |
childContainer.ComposeExportedValue(import); | |
return childContainer.GetExportedValue<TPart>(); | |
} |