Skip to content

Instantly share code, notes, and snippets.

View antonio-leonardo's full-sized avatar

Antonio Leonardo antonio-leonardo

View GitHub Profile
public class MemoryMappedStream : IDisposable
{
private bool disposedValue;
private readonly MemoryMappedFile _memoryMappedFile;
private MemoryMappedViewAccessor MemoryMappedViewAccessor { get; set; }
public bool IsMemoryNew
{
@antonio-leonardo
antonio-leonardo / BenchmarkExtension.cs
Created July 21, 2020 01:47
Simple benchmark class extension
/// <summary>
/// Class to provide benchmark performance tests.
/// Dependency: This class needs to create .Config file
/// </summary>
public static class BenchmarkExtension
{
/// <summary>
/// Query machine constants
/// </summary>
private const string QUERY_MACHINE = "SELECT * FROM Win32_Processor",
@antonio-leonardo
antonio-leonardo / MailSender.cs
Created July 18, 2020 19:39
Class with complete and stable structures for sending e-mail
/// <summary>
/// Classe com estruturas completas e estáveis para envio de E-mail
/// </summary>
public class MailSender
{
/// <summary>
/// Login do SMTP
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly string _smptLogin;
@antonio-leonardo
antonio-leonardo / Shp.RedefineMasterPage.ps1
Created July 18, 2019 21:38
Redefine Site Master Page to Seattle (the original SharePoint MasterPage)
##Script para redefinir master page
Add-PSSnapin Microsoft.SharePoint.PowerShell
# get site collection
$site = Get-SPSite http://sharepoint-sitecollection
# get site in site collection
$web = Get-SPWeb http://sharepoint-subsite
@antonio-leonardo
antonio-leonardo / Shp.DeleteShpCorruptedList.ps1
Created July 18, 2019 21:36
Delete a corrupted SharePoint list
##Script para Deletar Listas corrompidas
Add-PSSnapin Microsoft.SharePoint.PowerShell
#Get the Web
$web = Get-SPWeb "<SharePoint-site-URL>"
#Get the corrupted List
$list = $web.lists["corrupted list name"]
#Set the AllowDeletion Flag to True
$list.AllowDeletion = $true
@antonio-leonardo
antonio-leonardo / MsSql.GetAllForeignKeysConstraintsOfTable.sql
Last active July 18, 2019 20:48
Two sql statements to get all Foreign Keys from Table
DECLARE @TABLE_NAME AS VARCHAR(150)
SET @TABLE_NAME = 'TableName'
SELECT * FROM (
SELECT
f.name constraint_name
,OBJECT_NAME(f.parent_object_id) referencing_table_name
,COL_NAME(fc.parent_object_id, fc.parent_column_id) referencing_column_name
,OBJECT_NAME (f.referenced_object_id) referenced_table_name
@antonio-leonardo
antonio-leonardo / Shp.EmergencySPManagedAccountUpdate.ps1
Last active July 15, 2020 15:15
Update SharePoint Managed Account Password on all Farm Layers: IIS, Windows Services and SharePoint Services. The full article with the prerequisites to execute this script at this URL: https://github.com/antonio-leonardo/UpdateSharePointManagedAccountPassword or https://www.codeproject.com/Articles/5092791/Update-SharePoint-Managed-Account-Pass…
#########################################################################################################
#########################################################################################################
############################### Author: Antonio Leonardo de Abreu Freire ################################
#### Microsoft Certified ID: 13271836, vide https://www.youracclaim.com/users/antonioleonardo/badges ####
#########################################################################################################
## Update SharePoint Account Password on all Farm Layers: IIS, Windows Services and SharePoint Services #
#########################################################################################################
#########################################################################################################
########### Don't Forget this Script Premisses! The current user to execute this script needs: ##########
########### a)Belongs to Farm Administrator Group; ###################
@antonio-leonardo
antonio-leonardo / CSharp.StringProcessment.cs
Last active July 18, 2019 19:43
C# Extension class that constains several roles to manipulate strings and chars
//Author: Antonio Leonardo de Abreu Freire, Microsoft Certified ID: 13271836
using System;
using System.Web;
using System.Linq;
using System.Collections.Generic;
namespace ExtensionFunctions
{
/// <summary>
@antonio-leonardo
antonio-leonardo / MsSql.ShrinkerCursor.sql
Last active July 18, 2019 19:45
Sql Server: Cursor that automate shrink all logs
SET NOCOUNT ON;
DECLARE @name VARCHAR(MAX)
,@DBName SYSNAME
,@LogicalLogFile SYSNAME
,@SQL_CMD_ALTER_0 VARCHAR(MAX);
DECLARE clear_logs_cursor CURSOR FOR
SELECT name FROM master.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb');