Claudio Bosticco

Welcome to my site! I’m a 34-year-old developer specialized in .NET and I created this site as a public notebook, collecting what I find useful or interesting in my daily work. I hope these resources can help you and anyone looking for inspiration or assistance with their development projects.

SQL Server Reset Table Index

In case a table has an auto-incremental ID column, it may sometimes be appropriate to reset its base value (for example, after a truncate table). DBCC CHECKIDENT ('tableName', RESEED, 1)

November 1, 2024

SQL Server Count All Rows in All Tables

This query is used to count all rows in all tables of a database. CREATE TABLE #counts ( table_name varchar(255), row_count int ) EXEC sp_MSForEachTable @command1='INSERT #counts (table_name, row_count) SELECT ''?'', COUNT(*) FROM ?' SELECT table_name, row_count FROM #counts ORDER BY row_count DESC DROP TABLE #counts

November 1, 2024

SQL Server Backup Database via Query

To backup a SQL Server database using a SQL query, you need to use the following command: BACKUP DATABASE DatabaseName TO DISK ='C:\DBSQLBACKUP\DatabaseName.bak'

November 1, 2024

Linux Disk Space Maintenance

This section illustrates commands for optimizing space on Linux servers. Delete files with a certain extension You can use the find command specifying: directory to search (recursively) the -name tag to filter by extension the -delete tag to launch deletion of found files find /var/opt/docker -name *.bak -delete Find files larger than 1GB You can use the find command specifying: directory to search (recursively) the -name tag to filter by extension the -size tag to filter only files with size equal to or greater than 1 GB the -printf tag to print filename and size in KB find /var/opt/docker -name '*.ldf' -size +1G -printf "%p %k KB\n"

November 1, 2024

EF Migrations

This section illustrates useful commands for managing migrations. Adding a migration To add a migration, navigate to the folder where the solution file is located and use the following command: dotnet ef migrations add <<MigrationName>> --context LogicWayContext -p LogicWay.Core -s LogicWay It is important to specify the -p flag to indicate the project where the context is located and where to create the migration file, and also the -s flag to specify the solution, from which the command can determine which startup project contains the database connection string. ...

November 1, 2024

JavaScript Filter Map Reduce

These three functions are used to quickly manage data within lists. They are the JavaScript equivalent of LINQ. Filter The filter function allows you to extract certain elements from the array based on a function. const numbers = [1, 4, 5, 6, 4, 2, 5, 6, 3, 1]; const even = numbers.filter((x) => x % 2 === 0); console.log("Even numbers: ", even); Map The map function allows you to apply a function to each element of the list. const numbers = [1, 4, 5, 6, 4, 2, 5, 6, 3, 1]; const squares = numbers.map((x) => x * x); console.log("Squares: ", squares); Reduce The reduce function allows you to perform a function on each element of the list and returns an “accumulated” result. ...

November 1, 2024

7zip Guide

7-Zip can be used via console. To simplify its use, simply add the path to the executable to the system PATH. Archive 7z.exe a archive.7z .\sourcefile.ext Extract files 7z.exe e sourcefile.zip

November 1, 2024

Prevent Double Click Button ASP WebForms

To prevent inadvertent double-clicking of a Button in an ASP.NET WebForms project, you need to set the UseSubmitBehavior="false" tag: <asp:Button runat="server" OnClick="Execute_Click" Text="Execute" UseSubmitBehavior="false" OnClientClick="CheckDouble(this)"/> and invoke the following JavaScript: var submit = 0; function CheckDouble(bt) { //alert(submit); if (submit > 0) { bt.disabled = true; alert( "You have already clicked the button. Wait for the operation to complete" ); return false; } submit++; return true; }

November 1, 2024