Skip to content

Instantly share code, notes, and snippets.

View vpetkovic's full-sized avatar
👾

Vojislav Petkovic vpetkovic

👾
View GitHub Profile
@vpetkovic
vpetkovic / AAA.md
Created March 30, 2023 15:24 — forked from arkada38/AAA.md
Using Tailwind CSS v3.2 with Blazor (.Net 6 or above)

Using Tailwind CSS v3.2 with Blazor (.Net 6 or above)

This method works for Blazor Server and Blazor WebAssembly with hot reload, style isolation and tailwind jit compilation.

Setup with using Standalone Tailwind CSS CLI without Node.js

For this method you need added to path Tailwind CSS CLI binary. Read more about Standalone CLI.

Just create a StaticAssets folder in the root of your project with next structure.

@vpetkovic
vpetkovic / LTT.md
Created September 16, 2022 01:11 — forked from jehugaleahsa/LTT.md
LINQ Tricks and Techniques

Learn to Love LINQ

I've been using LINQ for years and I've come to deeply respect it as a technology. Unfortunately it has not been adopted by the .NET community as much as I would have expected. I honestly believe it is the single one feature that gives C# a competitive edge over many of the other general-purpose languages out there today. This document will go over some of the tricks I have learned to make the most of LINQ's powerful features. Hopefully you'll learn at least one trick along the way.

Query vs Method syntax

Yup, you can write your queries as a series of method calls or you can use the query syntax. Method syntax is fine when you're first starting out, but query syntax is more expressive in the long run. My experience has been that operations such as where, select, join, group by and order by should be expressed using query syntax and "reduce" operations should be done in method syntax. Unavoidably, you sometimes have to use method calls inside of your queries simply because th

@vpetkovic
vpetkovic / myTools.md
Last active February 12, 2022 20:44
My Development Tools

This is a list of the tools I use on daily basis to complete every single taks on hand more efficeintly. List is not set in stone so if you have any suggestions on the tool I should start using, drop the comment below explaining why I should check it out 😉.

⚙ IDEs

  • Visual Studio
  • JetBrains Tools (Rider, PHPStorm, WebStorm)
  • Visual Studio Code (not really as an IDE but for quick code peek and very light and quick editing

⚙ Data

@vpetkovic
vpetkovic / ShowClaimsPageRazor
Last active July 28, 2020 20:22
This is just a boilerplate to save a bit of time with copy paste when needed
@page "/Claims"
@inject AuthenticationStateProvider AuthState
<AuthorizeView>
<Authorized>
<h2>
Hello @Username,
here's the list of your claims:
</h2>
<ul>
#region Authorization Policies
// We have to first define policies
services.AddMvcCore(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
//.RequireClaim("Role", "Test")
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
@vpetkovic
vpetkovic / docker-clear.bat
Created June 8, 2020 16:37 — forked from daredude/docker-clear.bat
delete all docker container and images on windows
@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi %%i
@vpetkovic
vpetkovic / IdenittyServer4Migrations
Last active June 8, 2020 01:00
Using Pameelo MySQL provider. Hav to set charset collation to never append ` services.AddDbContext<AppDbContext>(config => { config.UseMySQL(_config.GetConnectionString("Default"), sql => sql
dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb
dotnet ef database update -c PersistedGrantDbContext
dotnet ef database update -c ConfigurationDbContext
@vpetkovic
vpetkovic / AppDbConectx.cs
Last active June 8, 2020 00:59
NETCore 3.1
using IdentityServer.Model;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace IdentityServer.Data
{
public class AppDbContext : IdentityDbContext<ApplicationUser>
{
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
@vpetkovic
vpetkovic / ConfigureSwaggerOptions.cs
Last active September 9, 2020 14:31
[NETCore 3.1]
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace SwaggerVersioning
{
// <summary>
/// Configures the Swagger generation options.
CREATE FUNCTION dbo.fnGetNthWeekdayOfMonth
(
@theDate DATETIME,
@theWeekday TINYINT,
@theNth SMALLINT
)
RETURNS DATETIME
BEGIN
RETURN (
SELECT theDate