Skip to content

Instantly share code, notes, and snippets.

View DamianEdwards's full-sized avatar
🏠
Working from home

Damian Edwards DamianEdwards

🏠
Working from home
View GitHub Profile
@DamianEdwards
DamianEdwards / Helpers.cs
Created February 20, 2014 19:39
Razor ideas
[TagHelper("@form")]
public static TagBuilder FormTagHelper(this RazorPage page, TagBuilder element, string action, string controller, IDictionary<string, string> route)
{
element.Attributes["action"] = Url.Action(action, controller, route);
// Could implicitly write out anti-forgery token as nested hidden input field here too
}
[TagHelper("@label")]
public static TagBuilder LabelTagHelper(this RazorPage page, TagBuilder element, string name, string @class)
@DamianEdwards
DamianEdwards / Program.cs
Last active August 29, 2015 14:04
See the clock and high frequency timer resolution of your PC from .NET
using System;
using System.Diagnostics;
using System.Threading;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
@DamianEdwards
DamianEdwards / Global.asax.cs
Created May 26, 2015 18:24
Control the CDN paths for ASP.NET 4.x scripts via the ScriptManager
using System;
using System.Reflection;
using System.Web;
using System.Web.UI;
namespace WebApplication34
{
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
@DamianEdwards
DamianEdwards / SquirrelSetup.log
Last active August 29, 2015 14:24
Atom hates me
Program: Starting Squirrel Updater: --install .
Program: Starting install, writing to C:\Users\Damian\AppData\Local\SquirrelTemp
CheckForUpdateImpl: Failed to load local releases, starting from scratch: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Damian\AppData\Local\atom\packages\RELEASES'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Squirrel.Utility.LoadLocalReleases(String localReleaseFile)
at Squirrel.UpdateManager.CheckForUpdateImpl.<CheckForUpdate>d__28.MoveNext()
CheckForUpdateImpl: Reading RELEASES file from C:\Users\Damian\AppData\Local\SquirrelTemp
CheckForUpd
@DamianEdwards
DamianEdwards / Program.cs
Created August 2, 2015 05:52
DateTime.ToString perf test when format string is fixed
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
namespace DateTimeFormatPerfTest
{
public class Program
{
private static object _locker = new object();
@DamianEdwards
DamianEdwards / gist:1654095
Created January 21, 2012 21:29
Moar Signalr
using System;
using System.Collections.Generic;
using System.Threading;
namespace SignalR.Infrastructure
{
internal class LockedList<T> : List<T>
{
private readonly ReaderWriterLockSlim _listLock = new ReaderWriterLockSlim();
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SignalR.Infrastructure;
namespace SignalR
@DamianEdwards
DamianEdwards / gist:1734345
Created February 4, 2012 01:41
Crazy TPL helper from SignalR for the day
public static Task Interleave<T>(Func<T, Action, Task> before, Func<Task> after, T arg)
{
var tcs = new TaskCompletionSource<object>();
var tasks = new[] {
tcs.Task,
before(arg, () => after().ContinueWith(tcs))
};
return tasks.Return();
}
@DamianEdwards
DamianEdwards / Program.cs
Created October 4, 2015 06:55
Quick test of system timer frequency vs. Environment.TickCount in .NET
using System;
namespace ConsoleApp3
{
public class Program
{
public void Main(string[] args)
{
var length = TimeSpan.FromSeconds(2);
var started = DateTime.UtcNow;