Wednesday, April 15, 2020

Cool highlighter for many languages and tools

I like it

windows container in docker

One of my tasks is to run Windows containers in docker.
Also, need to manage IIS.
I took part of the code here

The Dockerfile install aspnet windows container with 4.6.2 (because I using old code in my projects), enable in container IIS remote management and binding 443 port with SSL certificate
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.6.2
ARG source
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Install-WindowsFeature -Name Web-Mgmt-Service
RUN New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
#RUN New-NetFirewallRule -Action Allow -Direction Inbound -DisplayName IISManagement -Service WMSVC
RUN set-service -Name WMSVC -StartupType Automatic
RUN Get-Service -Name WMSVC | Start-Service
RUN net user admin 6H%*!k0*/I /ADD
RUN net localgroup administrators admin /add
#RUN New-WebBinding -Name 'Default Web Site' -IP '*' -Port 443 -Protocol https
RUN $newCert=New-SelfSignedCertificate -DnsName 'localhost' -CertStoreLocation cert:\LocalMachine\My; \
  New-WebBinding -Name 'Default Web Site' -Protocol 'https'; \
  $binding=Get-WebBinding -Name 'Default Web Site' -Protocol 'https'; \
  $binding.AddSslCertificate($newCert.GetCertHashString(),'my')
EXPOSE 80 443
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .

Thursday, February 20, 2020

GitInfo. How using versioning from Git Tag and C# projects (frameworks and core)

In all big or small companies, you might be using versioning, I recommend using GitInfo, because it is a simple project that will help you be more advance.

A huge plus of GitInfo project is that besides the library itself you don’t need anything else


For dotnet core projects, I enable support Git and make the first commit and after I add Git Tag "0.1.0".

Then I add NuGet package "GitInfo"

Next step you need to add AssemblyInfo.cs, better to Properties folder

using System.Reflection;

[assembly: AssemblyVersion (ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]

[assembly: AssemblyFileVersion (ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]

[assembly: AssemblyInformationalVersion (
    ThisAssembly.Git.SemVer.Major + "." + 
    ThisAssembly.Git.SemVer.Minor + "." + 
    ThisAssembly.Git.Commits + "-" + 
    ThisAssembly.Git.Branch + "+" + 
    ThisAssembly.Git.Commit)]




And last step change csproj, you need add 3 rows

<PropertyGroup>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    </PropertyGroup>

After that, you can use GitInfo and versioning anywhere

Good luck!!!

Thursday, January 24, 2019

Dynamic ASP.NET Core Configurations 🗒️ With Consul KV

It's Very nice post about konsul.

Background

Usually, the configurations in .NET and .NET Core apps are stored in the configuration files, such as App.config and Web.config, or appsettings.json; however, all of them have some disadvantages.
hard-coded configuration files
difficult to manage
For example, if we need to frequently change the configuration files due to some reasons, how can we solve this problem? We cannot modify them one by one if there are lots of machines!

What we want is managing the configuration in one place, the "configuration center". Here are some awesome projects that can help us solve this problem, such as Apollo, Consul, etc.

And in this article, I will introduce three ways using Consul KV store.

Thursday, November 8, 2018

MSSQL search and replace value in all tables

It's little script for replace value in database


declare @from as nvarchar(50);
declare @to as nvarchar(50);

set @from  =[dbo].[getstringUUIDFromString] ('c3a5fb3e-745a-11e8-a209-0050568411f7'); 
set @to  =[dbo].[getstringUUIDFromString] ('c3a5fb3e-745a-11e8-a209-0050568411f7'); 



DECLARE @CURSOR CURSOR;DECLARE @script AS NVARCHAR(MAX);
SET @CURSOR = CURSOR SCROLL
FOR
 SELECT 
 '
 if exists (select top 1 * from  ['+isc.TABLE_CATALOG+'].['+isc.TABLE_SCHEMA+'].['+isc.TABLE_NAME+'] where '+isc.COLUMN_NAME + ' in ('+@from+'))
 begin
 print ''['+isc.TABLE_CATALOG+'].['+isc.TABLE_SCHEMA+'].['+isc.TABLE_NAME+']'';

 
 update ['+isc.TABLE_CATALOG+'].['+isc.TABLE_SCHEMA+'].['+isc.TABLE_NAME+']
 set '+isc.COLUMN_NAME + ' = '+@to+'
 where '+isc.COLUMN_NAME + ' in ('+@from+')
end;
 '
FROM information_schema.columns  isc
where  TABLE_CATALOG='DiachokERP' and TABLE_SCHEMA='dbo'
and data_type = 'binary' and CHARACTER_MAXIMUM_LENGTH=16

OPEN @CURSOR

FETCH NEXT
FROM @CURSOR
INTO @script
 

WHILE @@FETCH_STATUS = 0
BEGIN

 EXEC(@script);
 --print @script
 FETCH NEXT
 FROM @CURSOR
 INTO @script
END
CLOSE @CURSOR
DEALLOCATE @CURSOR;


and converting string from uid to uuid

CREATE function [dbo].[getstringUUIDFromString](@stringUUID as varchar(50))
returns nvarchar(50)
as
begin
--Возврат Сред(GUID, 20, 4) + Прав(GUID, 12) + Сред(GUID, 15, 4) + Сред(GUID, 10, 4) + Лев(GUID, 8);
declare @buffer nvarchar(50)
select @buffer ='0x'+ substring(@stringUUID,20,4)+right(@stringUUID,12)+substring(@stringUUID,15,4)+substring(@stringUUID,10,4)+left(@stringUUID,8)

return @buffer
end

GO

Saturday, October 13, 2018

add packages gdi plus to net core on macos

brew install mono-libgdiplus


I took it here

Sunday, September 2, 2018

Core install

install old drivers

pnputil.exe -i -a .\driversname.inf


install certs

Set-Location -Path Cert:\LocalMachine\Root\
Import-Certificate -FilePath "C:\install\FOR_SQL_1C\certnameshutdown -r.cer"

mount iso with show disk

Mount-DiskImage -ImagePath 'D:\ISO\Windows Server 2012 Trial\9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO' -StorageType ISO -PassThru | Get-Volume


update SQL

.\setup.exe /Q /IACCEPTSQLSERVERLICENSETERMS /Action=Upgrade /InstanceName=MSSQLServer

update key(licence) SQL

.\setup.exe /q /ACTION=EditionUpgrade /INSTANCENAME=MSSQLSERVER /PID="insert your key" /IACCEPTSQLSERVERLICENSETERMS

Install patch

.\SQLServer2017-KB4464082-x64.exe /qs /IAcceptSQLServerLicenseTerms /Action=Patch /AllInstances

Sunday, August 5, 2018

Arduino

If You have next error in VS Code
"sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\sketch\build\preproc\ctags_target_for_gcc_minus_e.cpp: The system cannot find the path specified.
[Error] Exit with code=1"

information this https://github.com/Microsoft/vscode/issues/38985
you need change setting.json.
Set "output": "../build"


{
"sketch": "app.ino",
"board": "arduino:avr:leonardoeth",
"output": "../build"
}


and delete all folders in folder "build/sketch"