Skip to content

Instantly share code, notes, and snippets.

View jrusbatch's full-sized avatar

Justin Rusbatch jrusbatch

View GitHub Profile
(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();
}
public static class HtmlHelperExtensions
{
public static WebGrid<T> Grid<T>(
this HtmlHelper<PagedViewModel<T>> htmlHelper,
int rowsPerPage = 10) where T : class
{
return new WebGrid<T>(htmlHelper, rowsPerPage);
}
public static WebGrid<TModel> Grid<T, TModel>(
using (var client = new HttpClient())
{
var authTokenBytes = Encoding.UTF8.GetBytes("auth_key:");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(authTokenBytes));
await client.PostAsync("https://push.ducksboard.com/v/widget_id", new { value = timer.ElapsedMilliseconds }, new JsonMediaTypeFormatter());
}