Skip to content

Instantly share code, notes, and snippets.

View jrusbatch's full-sized avatar

Justin Rusbatch jrusbatch

View GitHub Profile
public static Task<BrokeredMessage> OnMessageAsyncWrapper(CancellationToken cancellationToken = default(CancellationToken))
{
var tcs = new TaskCompletionSource<BrokeredMessage>();
try
{
if (cancellationToken.IsCancellationRequested)
{
tcs.SetCanceled();
return tcs.Task;
}
### Keybase proof
I hereby claim:
* I am jrusbatch on github.
* I am jrusbatch (https://keybase.io/jrusbatch) on keybase.
* I have a public key whose fingerprint is 5761 701E 5034 D7F1 3808 CA1D C759 FEAD ED2E 3488
To claim this, I am signing this object:
(function(global) {
'use strict';
var BaseUri = 'http://query.yahooapis.com/v1/public/yql';
var DefaultParameters = {
diagnostics: true,
env: 'http://datatables.org/alltables.env'
};
public static class DbAsyncEnumerableExtensions
{
public static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IDbAsyncEnumerable<T> source)
{
Check.NotNull(source, "source");
return new DbAsyncEnumerableAdapter<T>(source);
}
private struct DbAsyncEnumerableAdapter<T> : IAsyncEnumerable<T>
{
(function (global, undefined) {
'use strict';
var $ = global.jQuery;
/* Do stuff */
}(this));
// Knockout JavaScript library v3.0.0beta
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function () {
var DEBUG = true;
(function (undefined) {
// (0, eval)('this') is a robust way of getting a reference to the global object
// For details, see http://stackoverflow.com/questions/14119988/return-this-0-evalthis/14120023#14120023
var window = this || (0, eval)('this'),

scriptcs

What is it?

scriptcs makes it easy to write and execute C# with a simple text editor.

While Visual Studio, and other IDEs, are powerful tools, they can sometimes hinder productivity more than they promote it. You don’t always need, or want, the overhead of a creating a new solution or project. Sometimes you want to just type away in your favorite text editor.

scriptcs frees you from Visual Studio, without sacrificing the advantages of a strongly-typed language.

<UsingTask TaskName="CombinePackageConfigs" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<PackageConfigFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<OutputPath ParameterType="System.String" Required="true" />
<CreatedFile ParameterType="Microsoft.Build.Framework.ITaskItem" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Using Namespace="System.IO" />
public void Execute(string code, IEnumerable<string> references, IEnumerable<string> namespaces, ScriptPackSession scriptPackSession)
{
var host = _scriptHostFactory.CreateScriptHost(new ScriptPackManager(scriptPackSession.Contexts));
foreach (var context in scriptPackSession.Contexts) _scriptEngine.AddReference(context.GetType().Assembly);
var session = _scriptEngine.CreateSession(host);
foreach (var reference in references.Union(scriptPackSession.References).Distinct())
session.AddReference(reference);
private class FakeScriptPack : IScriptPack
{
public void Initialize(IScriptPackSession session)
{
}
public IScriptPackContext GetContext()
{
return new FakeScriptPackContext();
}