This file contains hidden or 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
class ReverseForLookupItem : ForLookupItemBase | |
{ | |
public ReverseForLookupItem([NotNull] PrefixExpressionContext context, | |
[NotNull] LiveTemplatesManager templatesManager, | |
[CanBeNull] string lengthPropertyName) | |
: base("forR", context, templatesManager, lengthPropertyName) { } | |
protected override IForStatement CreateStatement(CSharpElementFactory factory, ICSharpExpression expression) | |
{ | |
... |
This file contains hidden or 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
from contextlib import contextmanager | |
import logging | |
@contextmanager | |
def all_logging_disabled(highest_level=logging.CRITICAL): | |
""" | |
A context manager that will prevent any logging messages | |
triggered during the body from being processed. | |
:param highest_level: the maximum logging level in use. |
This file contains hidden or 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
//Provide an implementation of the abstract class Nat that represents non-negative integers | |
// | |
//Do not use standard numerical classes in this implementation. | |
//Rather, implement a sub-object and sub-class: | |
// | |
//class Zero : Nat | |
//class Succ(n: Nat) : Nat | |
// | |
//One of the number zero, then other for strictly positive numbers. | |
namespace Nat |
This file contains hidden or 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
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
This file contains hidden or 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
var hello = ""; | |
var enumerable = | |
EnumerableEx.Create<int>(async Yield => { | |
await Yield.Return(100); | |
await Yield.Return(200); | |
hello = "hello world"; | |
await Yield.Return(300); | |
}); | |
Console.WriteLine(enumerable.ElementAt(1)); // 200 | |
Console.WriteLine(hello); // empty |
This file contains hidden or 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 System; | |
using System.Collections.Generic; | |
using Autofac; | |
using Nancy; | |
using Nancy.Bootstrapper; | |
using Nancy.Bootstrappers.Autofac; | |
using Nancy.Hosting.Self; | |
using Nancy.Routing; | |
public class Bootstrapper : AutofacNancyBootstrapper |
This file contains hidden or 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 System; | |
using System.IO; | |
using System.Web.Http; | |
using System.Web.Http.SelfHost; | |
var address = "http://localhost:8080"; | |
var conf = new HttpSelfHostConfiguration(new Uri(address)); | |
conf.Routes.MapHttpRoute(name: "DefaultApi", | |
routeTemplate: "api/{controller}/{id}", | |
defaults: new { id = RouteParameter.Optional } |
This file contains hidden or 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 Order { | |
public int Id { get; set; } | |
public DateTime OrderedAt { get; set } | |
public IList<OrderLine> OrderLines { get; set } | |
public Person Customer { get; set } | |
} | |
public class OrderLine { | |
public int Id { get; set; } | |
public int Count { get; set; } |
This file contains hidden or 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 NSubstitute; | |
using Ploeh.AutoFixture; | |
using Ploeh.AutoFixture.AutoNSubstitute; | |
using Ploeh.AutoFixture.Xunit; | |
using Xunit.Extensions; | |
namespace AutofixtureDemo | |
{ | |
public class AutoNSubstituteDemo | |
{ |
This file contains hidden or 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
var Feedback = Backbone.Model.extend({ | |
url: '/feedback', | |
validate: function (attrs) { | |
var errors = []; | |
if (!attrs.email || attrs.email === '') { | |
errors.push({name: 'email', message: 'Please fill email field.'}); | |
} |