Skip to content

Instantly share code, notes, and snippets.

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

Bart Calixto Bartmax

🏠
Working from home
View GitHub Profile
private Dimention2D ComputeSize(Image image, int? maxWidth, int? maxHeight)
{
if (image == null) throw new ArgumentNullException(nameof(image));
if (maxWidth <= 0) throw new ArgumentOutOfRangeException(nameof(maxWidth));
if (maxHeight <= 0) throw new ArgumentOutOfRangeException(nameof(maxHeight));
if (image.Width <= 0) throw new ArgumentOutOfRangeException(nameof(image.Width));
if (image.Height <= 0) throw new ArgumentOutOfRangeException(nameof(image.Height));
var sourceDimension = new Dimention2D(image.Width, image.Height);
public class DevelpmentWallMiddleware
{
private readonly RequestDelegate _next;
private readonly string _password;
private readonly string _username;
public DevelpmentWallMiddleware(RequestDelegate next, string username, string password)
{
_next = next;
_username = username;
@Bartmax
Bartmax / PaginatedList.cs
Last active February 12, 2016 19:11
PaginatedList<T>
public static class IQueryableExtensions
{
public async static Task<PagedItems<T>> ToPagedItemsAsync<T>(this IQueryable<T> source, int pageSize, int pageIndex = 1)
{
var count = await source.CountAsync().ConfigureAwait(false);
var collection = await source
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize)
.ToListAsync().ConfigureAwait(false);
using Microsoft.AspNet.Razor.TagHelpers;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Hosting;
using System;
namespace ProjectName.TagHelpers
{
[HtmlTargetElement("html", Attributes = MinifyAttributeName)]
public class HtmlMinifierTagHelper : TagHelper