Skip to content

Instantly share code, notes, and snippets.

View khellang's full-sized avatar

Kristian Hellang khellang

View GitHub Profile
.css-truncate-button a{color:gray;margin-right:5px;text-decoration:none!important}.news .message,.open>.merge-branch-manually{max-width:inherit!important}@media (min-width:1400px){.container .repo-description.css-truncate-target,.css-truncate.css-truncate-target{white-space:normal!important;word-wrap:break-word!important}.capped-card{margin-right:10px!important;margin-left:10px!important}.container{width:1280px!important}.split-diff .container{padding-left:0!important;padding-right:0!important}.container .news{width:700px!important}.container .news .css-truncate.css-truncate-target{max-width:870px!important}.container .notifications-list .css-truncate,.container .notifications-list .css-truncate .css-truncate-target{max-width:500px!important}.container .repo-and-owner{max-width:370px!important}.container .repo-description.css-truncate-target{max-width:380px!important}.container .org-main{width:990px!important}.container .repo-list-description{max-width:950px!important}.container .repository-with-sidebar.with-
@khellang
khellang / Program.cs
Created October 23, 2015 11:58
Check namespace of all MVC controllers in a solution
public static class Program
{
private const string ControllerType = "System.Web.Mvc.Controller";
public static void Main(string[] args)
{
MainAsync(args).Wait();
}
private static async Task MainAsync(string[] args)
public interface ICommandHandler<in TCommand, out TResult>
{
TResult Execute(TCommand command);
}
public interface ICommandHandler<in TCommand> : ICommandHandler<TCommand, void>
{
}
public class CommandHandler : ICommandHandler<string>
using AppFunc = Func<IDictionary<string, object>, Task>;
using AddMiddleware = Action<Func<
Func<IDictionary<string, object>, Task>,
Func<IDictionary<string, object>, Task>
>>;
public class Startup
{
public void Configure(IApplicationBuilder app)
open System
open System.IO
open System.Security.Cryptography
type Arguments = { ByteCount: int64; Path: string; }
let (|Long|_|) str =
match Int64.TryParse(str) with
| (true, int) -> Some(int)
| _ -> None
@khellang
khellang / script.csx
Last active December 22, 2015 17:12
scriptcs running a self-hosted OWIN application
#r Owin;
#r Microsoft.Owin.Hosting;
using Owin;
using Microsoft.Owin.Hosting;
var url = "http://localhost:8080";
using (WebApp.Start(url, Configure))
{
public static class ObservableExtensions
{
public static IObservable<TResult> WithLatestFrom<TResult, TFirst, TSecond>(
this IObservable<TFirst> first,
IObservable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector)
{
return second.Select(a => first.Select(b => resultSelector(b, a))).Switch();
}
}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
public class C
{
public async Task<IEnumerable<string>> M()
{
return await N();
}

Results 10,000,000 iterations:

Start

Method Time
IndexerEquals 31ms
CharIndexOfEquals 102ms
StartsWith [Ordinal] 138ms
SubstringEquals 179ms
# PowerShell + HTML5 prototype. Needs audio. Run: iex (New-Object Net.WebClient).DownloadString("https://gist.githubusercontent.com/khellang/8c708cd511125fab134b/raw/7d34a68073b715a3d19d1f6041637a8de6be9802/Invoke-PSHtml5.ps1")
$data = 'H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In638zpb5E36Wfp7biUpPR+lP/ZjvyeeH//xH/89f5x/0C9Dz4/rvz/2ex4+0kd+Ofz4k0/MewIC/3zyyScfH9Lz6PDwx3/s95T2I/Pio0O8Ii/5nX/Cb/ivcGN57BsGGfcKnuAVfcn1gtbyAr3ycfwVfklesQ+N4uNPOq+M+D8e/CH+k3af8JtoT80+1p+2l5G05v/jM3mBn48/jr4ywiNIDb1yqDT2X9Fh8D+fdF5BYzct/iv8EX7EXzGd4BWLlyHZx+EL/M7Hn0gX+goTzL3i3vjkYzsY/ONeca39Vyyl5SWlQu8V6evjT7Qffsdy5MeHOlp5xcMLvXzM73Dbj/kfDIbJaSkWIPboUBoyWh8zmvrKobxlGMbh9ejRJwYzxsiMwgB8pETmF/i/kTcY88rH+oq8Frwykp68mWFS8TsOcXnFodV9xcyle8N/ZSTI4ZVDeeHHzSuuE6bYj3sA7MedXjqvuF70gQx0MDv8xBLMUExe0bfwsXTz4zKX4JdPPu73gn91goCG6cYg9uM//nHwiocXXsIcB4ihHesL5jKn+vxXwjf0FXnL9WIHj1eUy0LEftyozd9Te/FeYXViujGY/binC90rShJp+ONWyAxizgJAkN3DL2DSuTH+wc/eK9q