Skip to content

Instantly share code, notes, and snippets.

Ibrahim Šuta Ibro

Block or report user

Report or block Ibro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Dockerfile
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
View config.yml
version: 2
jobs:
build:
machine: true
steps:
- checkout
# build image
- run: |
docker info
View Span.cs
using System;
using System.Collections.Generic;
namespace SpanOfT_Dev
{
public class Program
{
private static void Main(string[] args)
{
int[] arr = { 1, 2, 3, 4, 5 };
View Span.cs
using System;
using System.Collections.Generic;
namespace SpanOfT_Dev
{
public class Program
{
private static void Main(string[] args)
{
int[] arr = { 1, 2, 3, 4, 5 };
View Span.cs
using System;
namespace SpanOfT_Dev
{
public class Program
{
private static void Main(string[] args)
{
int[] arr = { 0, 1, 2, 3, 4, 5 };
Span<int> span = arr.AsSpan();
@Ibro
Ibro / Span.cs
Created May 23, 2018
More C# 7 goodness - Span<T> - Span of T - CodingBlast
View Span.cs
int[] arr = { 0, 1, 2, 3, 4, 5 };
Span<int> span = arr.AsSpan();
foreach (var number in span)
{
Console.WriteLine(number);
}
View CategoriesController.cs
[HttpPost]
[ValidateAntiForgeryToken]
[AuthorizeResource(typeof(InsertCategoryRequirement))]
public async Task<IActionResult> Create([Bind("Id,Name,UserId")] Category category)
{
ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", category.UserId);
// If ModelState isn't valid, return to view immediately
if (!ModelState.IsValid)
{
View AuthorizeResourceAttribute.cs
public class AuthorizeResourceAttribute : TypeFilterAttribute
{
public AuthorizeResourceAttribute(Type requirementType)
: base(typeof(AuthorizeResourceFilter))
{
Arguments = new object[] { requirementType };
}
private class AuthorizeResourceFilter : IAsyncActionFilter
{
View CategoriesController.cs
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Name,UserId")] Category category)
{
var authorizationResult = await _authorizationService.AuthorizeAsync(User, category, new InsertCategoryRequirement());
if (!authorizationResult.Succeeded) // If user has no access show him 403
{
return new ForbidResult();
}
You can’t perform that action at this time.