Clear the NuGet Package Cache using the Command Line
dotnet nuget locals all --clear
Daily Notes of a Programmer
dotnet nuget locals all --clear
Removed all .NET packages
sudo apt remove 'dotnet*' sudo apt remove 'aspnetcore*'
Deleted PMC repository from APT, by deleting the repo .list file
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
Install .NET 7 SDK
sudo apt update
apt-get install -y dotnet-sdk-7.0
_Imports.razor
@using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components.Authorization
Pages/ProceduralLogic.razor:
@page "/procedural-logic" @inject IAuthorizationService AuthorizationService <h1>Procedural Logic Example</h1> <button @onclick="@DoSomething">Do something important</button> @code { [CascadingParameter] private Task<AuthenticationState>? authenticationState { get; set; } private async Task DoSomething() { if (authenticationState is not null) { var authState = await authenticationState; var user = authState?.User; if (user is not null) { if (user.Identity is not null && user.Identity.IsAuthenticated) { // ... } if (user.IsInRole("Admin")) { // ... } if ((await AuthorizationService.AuthorizeAsync(user, "content-editor")) .Succeeded) { // ... } } } } }
References
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-6.0#procedural-logic
dotnet package add Install-Package NetEscapades.AspNetCore.SecurityHeaders
public void Configure(IApplicationBuilder app) { app.UseSecurityHeaders(); // other middleware e.g. static files, MVC etc }
References
https://github.com/andrewlock/NetEscapades.AspNetCore.SecurityHeaders
dotnet add package OwaspHeaders.Core
app.UseSecureHeadersMiddleware( SecureHeadersMiddlewareExtensions .BuildDefaultConfiguration() );
References
https://github.com/GaProgMan/OwaspHeaders.Core
https://owasp.org/www-project-secure-headers/
Last Updated on May 29, 2023
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
/etc/systemd/system/v2ray.service
[Unit] Description=V2Ray Service Documentation=https://www.v2fly.org/ After=network.target nss-lookup.target [Service] User=nobody CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE NoNewPrivileges=true ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json Restart=on-failure RestartPreventExitStatus=23 [Install] WantedBy=user. Target
installed: /usr/local/bin/v2ray installed: /usr/local/share/v2ray/geoip.dat installed: /usr/local/share/v2ray/geosite.dat installed: /usr/local/etc/v2ray/config.json installed: /var/log/v2ray/ installed: /var/log/v2ray/access.log installed: /var/log/v2ray/error.log installed: /etc/systemd/system/v2ray.service installed: /etc/systemd/system/[email protected]
systemctl enable v2ray; systemctl start v2ray
Remove V2Ray
# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove
References
https://github.com/v2fly/fhs-install-v2ray
vi /etc/sysctl.conf
vm.panic_on_oom=1 ;enables panic on OOM kernel.panic=10 ;tells the kernel to reboot ten seconds after panicking
Delete Local Branch
git branch -d <branch_name> git branch -D <branch_name>
Delete Remote Branch
git push <remote_name> --delete <branch_name>
References
https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely
0.0.0.0/0 is the IPv4 everything – all possible IPv4 addresses.
::/0 is the IPv6 equivalent of that.
It should be noted that depending on implementation ::/0 can mean either all IPv6 addresses or all IPv4 and IPv6 addresses. That’s because IPv4 addresses can be mapped into IPv6 addresses ::ffff:0:0/96
References
https://serverfault.com/questions/874407/difference-between-0-0-0-0-0-and-0-in-access-control-lists
sudo apt install fail2ban -y
sudo systemctl enable fail2ban sudo systemctl start fail2ban
sudo systemctl status fail2ban
Configuring Fail2ban
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail. Local
sudo nano /etc/fail2ban/jail. Local
References
https://www.howtoforge.com/how-to-install-fail2ban-on-ubuntu-22-04/