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
protected internal sealed override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, | |
CancellationToken cancellationToken) | |
{ | |
if (request == null) | |
{ | |
throw new ArgumentNullException("request", SR.net_http_handler_norequest); | |
} | |
// ProcessRequest() and ProcessResponse() are supposed to be fast, so we call ProcessRequest() on the same | |
// thread SendAsync() was invoked to avoid context switches. However, if ProcessRequest() throws, we have |
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 static OperationDescription[] AddHelpOperations(ContractDescription contractDescription, DispatchRuntime dispatchRuntime) | |
{ | |
Fx.Assert(contractDescription != null, "The 'contractDescription' parameter should not be null."); | |
Fx.Assert(dispatchRuntime != null, "The 'dispatchRuntime' parameter should not be null."); | |
Uri baseAddress = dispatchRuntime.EndpointDispatcher.EndpointAddress.Uri; | |
HelpPage helpPage = new HelpPage(baseAddress, null, contractDescription); | |
HttpOperationDescription helpPageOperation = new HttpOperationDescription(HelpPage.HelpMethodName, contractDescription); | |
helpPageOperation.Behaviors.Add(new WebGetAttribute() { UriTemplate = HelpPage.OperationListHelpPageUriTemplate }); |
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
CallContext.SetData("key", new Number { N = 1 }); | |
var task1 = Task.Factory.StartNew(() => | |
{ | |
var n = CallContext.GetData("key") as Number; | |
n.N++; | |
Thread.Sleep(1000); | |
}); | |
var task2 = Task.Factory.StartNew(() => | |
{ |
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 TreeAnalyzer | |
{ | |
public Node FindCommonRoot(IEnumerable<Node> nodes) | |
{ | |
var walkedNodes = new HashSet<Node>(); | |
var branches = nodes.ToList(); | |
int nextIterationBranchRangeStartIndex = 0; | |
do | |
{ | |
for (int i = nextIterationBranchRangeStartIndex; i < branches.Count; i++) |
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
[TestFixture] | |
public class TimeToLiveTests | |
{ | |
[Test] | |
public void never_expiring_ttl_should_not_expire_at_relative_time() | |
{ | |
TimeToLive.CreateNeverExpiring().ExpiresAtRelativeTime.Should().BeFalse(); | |
} | |
[Test] |
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
JavaScript learning resources. | |
Starting point for those, who have already learned JS, but forgotten. Good article. Quite compact. | |
https://developer.mozilla.org/en/JavaScript/A_re-introduction_to_JavaScript | |
Question: what's the best learning source on JS. Some answers. | |
http://stackoverflow.com/questions/11246/best-resources-to-learn-javascript | |
http://stackoverflow.com/questions/2687566/learning-javascript-in-one-weekend | |
http://net.tutsplus.com/tutorials/javascript-ajax/the-best-way-to-learn-javascript/ |
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
function addMethod(object, name, fn){ | |
// Save a reference to the old method | |
var old = object[ name ]; | |
// Overwrite the method with our new one | |
object[ name ] = function(){ | |
// Check the number of incoming arguments, | |
// compared to our overloaded function | |
if ( fn.length == arguments.length ) | |
// If there was a match, run the function |
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
// type declaration | |
var A = makeType({ | |
init: function(x, y){ | |
this.x = x; | |
this.y = y; | |
}, | |
hello: function(){ | |
console.log(this.x, this.y) | |
} |
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
// type declaration | |
var A = makeType({ | |
init: function(x, y){ | |
this.x = x; | |
this.y = y; | |
}, | |
hello: function(){ | |
console.log(this.x, this.y) | |
} |
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
// inspired by this http://stackoverflow.com/a/12506613 | |
// + emit SIGINT, and handle "exit" event | |
var stdin = process.stdin; | |
// without this, we would only get streams once enter is pressed | |
stdin.setRawMode( true ); | |
// resume stdin in the parent process (node app won't quit all by itself | |
// unless an error or process.exit() happens) |
OlderNewer