Skip to content

Instantly share code, notes, and snippets.

View vmandic's full-sized avatar
🤠
chillin'

Vedran Mandić vmandic

🤠
chillin'
View GitHub Profile
@vmandic
vmandic / dotnet-tests-package.json
Created March 15, 2023 09:50
Run all dotnet tests in /test directory with npm / yarn command
"test": "for file in $(find ./tests -name '*.csproj'); do dotnet test $file || exit; done"
@vmandic
vmandic / .bash_profile
Last active May 1, 2022 18:04
Useful for setting terminal prompt on macOS or linux
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u \[\033[32m\]\w\$(parse_git_branch)\[\033[00m\]\n$ "
# removes annoying startup message
export BASH_SILENCE_DEPRECATION_WARNING=1
@vmandic
vmandic / PostCodeCheck.cs
Created February 8, 2021 15:29
Croatian post code number with HR prefix checker
private static bool IsCroatianPostOfficeNumberWithHRPrefix(string postCode)
{
// ref: https://hr.wikipedia.org/wiki/Po%C5%A1tanski_broj
if (postCode.StartsWith("HR"))
{
var postCodeWithoutHR = postCode.Substring(2);
if ( postCodeWithoutHR.StartsWith("10")
@vmandic
vmandic / Program.cs
Created December 24, 2020 15:07
How to inject custom IConfiguration in Startup.cs CTOR
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
namespace StartupIConfigurationInjectionProblem
{
public class Program
@vmandic
vmandic / create-aspnet-core-identity-schema.sql
Created December 29, 2019 14:46 — forked from akatakritos/create-aspnet-core-identity-schema.sql
Script to create the ASPNET core Identity tables
USE [HobbyDB]
GO
/****** Object: Table [dbo].[AspNetRoleClaims] Script Date: 6/4/2018 10:18:03 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNetRoleClaims]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AspNetRoleClaims](
@vmandic
vmandic / Documentation.cs
Created July 3, 2019 20:32 — forked from hlaueriksson/Examples.cs
PuppeteerSharp Basic Tests
using System;
using System.Threading.Tasks;
using Xunit;
namespace PuppeteerSharp.Extensions.Tests
{
public class Documentation
{
[Fact]
public async Task download_Chromium()
@vmandic
vmandic / Startup.cs
Created May 23, 2019 20:37
meds-processor, part/4, snippet #23
using AspNetCoreRateLimit;
using MedsProcessor.Scraper;
using MedsProcessor.WebAPI.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace MedsProcessor.WebAPI
{
@vmandic
vmandic / IServiceCollectionExtensions.cs
Last active May 23, 2019 20:36
meds-processor, part/4, snippet #22
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using AspNetCoreRateLimit;
using MedsProcessor.Common.Models;
using MedsProcessor.Downloader;
using MedsProcessor.Parser;
using MedsProcessor.Scraper;
@vmandic
vmandic / ErrorController.cs
Last active May 23, 2019 20:22
meds-processor, part/4, snippet #21
using MedsProcessor.WebAPI.Infrastructure;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
namespace MedsProcessor.WebAPI.Controllers
{
[ApiVersionNeutral, Route("api/[controller]")]
public class ErrorController : ApiControllerBase
{
/// <summary>
@vmandic
vmandic / IApplicationBuilderExtensions.cs
Created May 23, 2019 13:53
meds-processor, part/4, snippet #20
using System;
using MedsProcessor.WebAPI.Infrastructure;
using Microsoft.AspNetCore.Builder;
namespace MedsProcessor.WebAPI.Extensions
{
public static class IApplicationBuilderExtensions
{
public static IApplicationBuilder UseBasicAuthentication(
this IApplicationBuilder app,