Skip to content

Instantly share code, notes, and snippets.

public record OperationResult<TResult>
{
public TResult? Response { get; private set; }
public bool Success { get; private set; }
public string? ErrorMessage { get; private set; }
public Exception? Exception { get; private set; }
public static OperationResult<TResult> BuildSuccess(TResult result)
{
@codehaks
codehaks / OperationResult.cs
Created December 14, 2022 13:28
Operation Result Pattern
public record OperationResult<TResult>
{
public TResult? Response { get; private set; }
public bool Success { get; private set; }
public string? ErrorMessage { get; private set; }
public Exception? Exception { get; private set; }
public static OperationResult<TResult> BuildSuccess(TResult result)
{
@codehaks
codehaks / Startup.cs
Created September 3, 2021 14:58
Marten Option
private Marten.StoreOptions BuildStoreOptions()
{
var connectionString = Configuration.GetConnectionString("Marten");
var options = new Marten.StoreOptions();
options.Connection(connectionString);
options.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;
return options;
}
@codehaks
codehaks / SQL Docker Commands
Created May 12, 2021 08:03
SQL server Docker
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=1234@Abcd" -p 1500:1433 --name sql1 -h sql1 -d mcr.microsoft.com/mssql/server:2019-latest
docker exec -it sql1 "bash"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "1234@Abcd"
@codehaks
codehaks / note.txt
Last active May 10, 2021 20:31
SQL Server on docker remote
docker run -m=4g -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=1234@Abcd" -p 1433:1433 --name sql2 -h sql2 -d mcr.microsoft.com/mssql/server:2019-latest
docker exec -it sql2 "bash"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "1234@Abcd"
sqlcmd -S 127.0.0.1,1434 -U SA -P "1234@Abcd"
[Route("api/user/roles")]
public IActionResult UserRoles()
{
var q1 = from userRole in _shopDbContext.UserRoles
join role in _shopDbContext.Roles on userRole.RoleId equals role.Id
join user in _shopDbContext.Users on userRole.UserId equals user.Id
select new
{
user.Id,
user.FirstName,
@codehaks
codehaks / excuses.json
Created January 31, 2021 16:46 — forked from mhmda-83/excuses.json
Devloper Excuses (extracted from http://developerexcuses.com/)
[
"That code seemed so simple I didn't think it needed testing",
"That isn't covered by my job description",
"I can't test everything",
"That's not a bug it's a configuration issue",
"That wasn't in the original specification",
"It's just some unlucky coincidence",
"Oh, you said you DIDN'T want that to happen?",
"There were too many developers working on that same thing",
"I have too many other high priority things to do right now",
@codehaks
codehaks / launchsettings.json
Created December 6, 2020 19:03
Tye run in VS
"Tye": {
"commandName": "Executable",
"executablePath": "tye",
"commandLineArgs": "run",
"workingDirectory": "$(SolutionDir)",
"launchBrowser": true,
"launchUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
@codehaks
codehaks / launchsettings.json
Created November 23, 2020 07:32
dotnet watch visual studio
"Watch": {
"commandName": "Executable",
"executablePath": "dotnet.exe",
"workingDirectory": "$(ProjectDir)",
"commandLineArgs": "watch run",
"launchBrowser": true,
"launchUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
import turtle
t=turtle.getturtle()
t.speed(100)
t.fillcolor("yellow")
t.begin_fill()
t.pensize(5)
t.pencolor("black")