Skip to content

Instantly share code, notes, and snippets.

@CrazyMORF
CrazyMORF / ConsoleNoDeadlockOnWait.cs
Created April 1, 2016 10:24
There is no deadlock on Wait at line 17
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
static async Task Work()
{
await Task.Delay(1000);
@CrazyMORF
CrazyMORF / MVCDeadlockOnWait.cs
Created April 1, 2016 10:22
Index action lock at line 18
using System.Threading;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace WebApplication5.Controllers
{
public class HomeController : Controller
{
static async Task Work()
{
@CrazyMORF
CrazyMORF / GeneratedContentFilter.cs
Last active August 29, 2015 14:20
Combres filter that provides content using generators
using Combres;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Helpers;
namespace WebApplication7
{
/// <summary>
@CrazyMORF
CrazyMORF / gist:d6f1ad10184a820385e4
Created April 8, 2015 11:07
OwinOAuthProviders Linkedin fix
// Request the token
HttpResponseMessage tokenResponse =
await httpClient.GetAsync(string.Format("{0}?grant_type=authorization_code&code={1}&redirect_uri={2}&client_id={3}&client_secret={4}",
TokenEndpoint, code, redirectUri, Options.ClientId, Options.ClientSecret));
@CrazyMORF
CrazyMORF / VersionedRazorViewEngine.cs
Last active August 29, 2015 14:07
Razor View Engine that supports view "versioning" determined from RouteData
using System.Web.Mvc;
namespace VersionedViewEngineBench.Helpers
{
/* Add to Global.asax.cs
// Clears all previously registered view engines.
ViewEngines.Engines.Clear();
// Registers our Razor C# specific view engine.
ViewEngines.Engines.Add(new VersionedRazorViewEngine());
@CrazyMORF
CrazyMORF / EasterSunday.cs
Last active August 29, 2015 14:05
Easter Sunday
public static DateTime EasterSunday(int year)
{
int day = 0;
int month = 0;
int g = year % 19;
int c = year / 100;
int h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g + 15) % 30;
int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h + 1)) * (int)((21 - g) / 11));
@CrazyMORF
CrazyMORF / MacOS_like_box-shadow.css
Last active November 20, 2023 20:22
MacOS like box-shadow
.box {
box-shadow: 0 22px 70px 4px rgba(0, 0, 0, 0.56);
}