I hereby claim:
- I am sebnilsson on github.
- I am sebnilsson (https://keybase.io/sebnilsson) on keybase.
- I have a public key ASCWYybMp3SXcq0oy9xFjsdWBwizgfPCOEE1sCL7ke-Gmwo
To claim this, I am signing this object:
public static HttpContext GetFakeHttpContext( | |
string url, | |
HttpRequest request = null, | |
HttpResponse response = null) | |
{ | |
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) | |
{ | |
throw new ArgumentOutOfRangeException("url", "The URL must be a well-formed absolute URI."); | |
} |
public static class HashAlgorithmExtensions | |
{ | |
private const int BufferSize = 4096; | |
public static async Task<byte[]> ComputeHashAsync(this HashAlgorithm hash, Stream inputStream) | |
{ | |
if (hash == null) throw new ArgumentNullException(nameof(hash)); | |
if (inputStream == null) throw new ArgumentNullException(nameof(inputStream)); | |
hash.Initialize(); |
Sub ConvertWordsToPdfs() | |
Dim directory As String | |
directory = "C:\Wordup" ' The starting directory | |
Dim fso, folder, files | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set folder = fso.GetFolder(directory) | |
Set files = folder.files |
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
public static double GetEpochTicks(this DateTime dateTime) | |
{ | |
return dateTime.Subtract(Epoch).TotalMilliseconds; | |
} |
I hereby claim:
To claim this, I am signing this object:
public static void Main(string[] args) | |
{ | |
var components = RegisterComponents(); | |
Run(components); | |
} | |
private static IContainer RegisterComponents() | |
{ | |
var builder = new ContainerBuilder(); |
[HtmlTargetElement("html-encode", TagStructure = TagStructure.NormalOrSelfClosing)] | |
public class HtmlEncodeTagHelper : TagHelper | |
{ | |
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) | |
{ | |
var childContent = output.Content.IsModified | |
? output.Content.GetContent() | |
: (await output.GetChildContentAsync()).GetContent(); | |
string encodedChildContent = WebUtility.HtmlEncode(childContent ?? string.Empty); |
public static ExpandoObject ToExpandoObject(this object obj) | |
{ | |
if (obj == null) | |
throw new ArgumentNullException(nameof(obj)); | |
IDictionary<string, object> expando = new ExpandoObject(); | |
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(obj.GetType())) | |
expando.Add(property.Name, property.GetValue(obj)); |
public static string ToRelative(this Uri uri) | |
{ | |
if (uri == null) | |
{ | |
throw new ArgumentNullException(nameof(uri)); | |
} | |
return uri.IsAbsoluteUri ? uri.PathAndQuery : uri.OriginalString; | |
} |
public static class DateTimeRfc3339Extensions | |
{ | |
public static string ToRfc3339String(this DateTime dateTime) | |
{ | |
string rfc3339 = dateTime.ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz", DateTimeFormatInfo.InvariantInfo); | |
return rfc3339; | |
} | |
} |