Skip to content

Instantly share code, notes, and snippets.

View eramax's full-sized avatar
🎯
Focusing

Ahmed Morsi eramax

🎯
Focusing
View GitHub Profile
@eramax
eramax / postgres_docker-compose.yml
Created February 8, 2022 19:49
postgres docker-compose.yml
version: "3.9"
services:
postgres:
container_name: postgres-container
image: postgres
restart: always
ports:
- '5432:5432'
volumes:
- ./db:/var/lib/postgresql/data
@eramax
eramax / portainer_docker-compose.yml
Created February 8, 2022 19:48
portainer docker-compose.yml
version: "3.9"
services:
portainer:
image: portainer/portainer-ce:latest
ports:
- 9000:9000
container_name: portainer
# username: admin , password: 123 , hash command : htpasswd -nb -B admin 123 | cut -d ":" -f 2
command: --admin-password "$$2y$$05$$aZhNvtX9GSAIUXPbfKq6dudTMuJcJuLnwWmz2HBnBq23fAlzrAyeu" -H unix:///var/run/docker.sock
volumes:
function getHightlightCoords() {
var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var selected = selectionRects.map(function (r) {
return viewport.convertToPdfPoint(r.left - pageRect.x, r.top - pageRect.y).concat(
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
});
@eramax
eramax / NetArch.cs
Created October 26, 2021 18:37
NetArchTests
using NetArchTest.Rules;
using WebApi2.Services;
using Xunit;
/// <summary>
/// NetArchTest
/// https://github.com/BenMorris/NetArchTest
/// </summary>
namespace NetArch
{
@eramax
eramax / FluentAssertions.cs
Created October 11, 2021 19:19
How to write cleaner unit tests with Fluent Assertions in .NET Core
using DataLib;
using FluentAssertions;
using NSubstitute;
using NSubstitute.ReturnsExtensions;
using System;
using WebApi2.Models;
using WebApi2.Services;
using Xunit;
/// <summary>
@eramax
eramax / NSubstitute.cs
Created October 11, 2021 17:57
Clean mocking for unit tests using NSubstitute in .NET
using DataLib;
using NSubstitute;
using NSubstitute.ReturnsExtensions;
using WebApi2.Models;
using WebApi2.Services;
using Xunit;
/// <summary>
/// Clean mocking for unit tests using NSubstitute in .NET (Core, Framework, Standard)
/// https://www.youtube.com/watch?v=LcQYv0cBWk0&
@eramax
eramax / TestCoverage.cs
Created September 26, 2021 16:40
Code coverage of your tests in .NET
using App1;
using Xunit;
/// <summary>
/// How to collect the code coverage of your tests in .NET
/// https://www.youtube.com/watch?v=xwMWGYD8rgk
/// Calculate code coverage by cli command
/// dotnet tool install -g coverlet.console
/// coverlet .\bin\Debug\net5.0\App1.dll --target "dotnet" --targetargs "test --no-build"
/// dotnet test --collect:"XPlat Code Coverage"
@eramax
eramax / Mapster.cs
Created September 26, 2021 10:50
Mapster mapper
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Mapster;
using System;
/// <summary>
/// Mapster, the best .NET mapper that you are (probably) not using
/// https://www.youtube.com/watch?v=UIslFVEHkzA
/// </summary>
public class Program
@eramax
eramax / functional.cs
Last active September 26, 2021 05:49
Functional Programming with C# - Simon Painter
/// <summary>
/// Functional Programming with C# - Simon Painter - NDC Oslo 2020
/// https://www.youtube.com/watch?v=gvyTB4aMI4o
/// </summary>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
@eramax
eramax / extend-trial-jetbrains-windows.bat
Created September 25, 2021 11:50
JetBrains IDE trial reset windows
REM Delete eval folder with licence key and options.xml which contains a reference to it
for %%I in ("WebStorm", "IntelliJ", "CLion", "Rider", "GoLand", "PhpStorm", "Resharper", "PyCharm") do (
for /d %%a in ("%USERPROFILE%\.%%I*") do (
rd /s /q "%%a/config/eval"
del /q "%%a\config\options\other.xml"
)
)
REM Delete registry key and jetbrains folder (not sure if needet but however)
rmdir /s /q "%APPDATA%\JetBrains"