Skip to content

Instantly share code, notes, and snippets.

@jagregory
jagregory / Restish.cs
Created May 4, 2011 13:51
Watch out NancyFX!
public class Api : Restish
{
Api()
{
Get("/customers", (req, res) =>
{
return View(new[]
{
new { name = "Charles" }
});
@jagregory
jagregory / AutoMapperExtensions.cs
Created April 27, 2011 14:31
NullSafeMapFrom extension for AutoMapper
public static class AutoMapperExtensions
{
public static void NullSafeMapFrom<T, TResult>(this IMemberConfigurationExpression<T> opt, Expression<Func<T, TResult>> sourceMemberExpression)
{
var sourceMember = sourceMemberExpression.Compile();
opt.MapFrom(src =>
{
try
{
public class MyClassMap: ClassMap<MyClass>
{
public MyClassMap()
{
Id(x => x.Id)
.Column("MyClassId")
.GeneratedBy.HiLo("100");
Map(x => x.Something)
.Length(150);
@Path("/customers")
class CustomerResource {
@GET
@Produces(Array(MediaType.APPLICATION_JSON))
@Path("{id}")
def getJson(@PathParam("id") id: Int) =
"Id requested was: " + id.toString()
}
@Path("/customers")
class CustomerResource {
@GET
def get =
"[{ 'name': 'James' }, { 'name': 'Gregory' }]"
@GET
def get(id) =
"{ 'name': 'James' }"
}
public class MyEnum
{
public static readonly MyEnum Value1 = new MyEnum("value1");
public static readonly MyEnum Value2 = new MyEnum("value2");
readonly string name;
MyEnum(string name)
{
this.name = name;
Establish context = () =>
controller = Container.Resolve<OrderController>();
@jagregory
jagregory / app.coffee
Created January 15, 2011 13:05
Mmmmm node
app.post '/buy', (req, res) ->
googleCheckout.sendInitialOrderRequest req, (redirectUrl) ->
res.redirect redirectUrl
git status:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: file -> elif
#
commit:
public class Task<T>
{
readonly T something;
public Task(T something)
{
this.something = something;
}
}