Skip to content

Instantly share code, notes, and snippets.

Avatar

Antonio Leonardo antonio-leonardo

View GitHub Profile
@antonio-leonardo
antonio-leonardo / MsSql.ShrinkerCursor.sql
Last active Jul 18, 2019
Sql Server: Cursor that automate shrink all logs
View MsSql.ShrinkerCursor.sql
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');
@antonio-leonardo
antonio-leonardo / CSharp.StringProcessment.cs
Last active Jul 18, 2019
C# Extension class that constains several roles to manipulate strings and chars
View CSharp.StringProcessment.cs
//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 / Shp.EmergencySPManagedAccountUpdate.ps1
Last active Jul 15, 2020
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…
View Shp.EmergencySPManagedAccountUpdate.ps1
#########################################################################################################
#########################################################################################################
############################### 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 / MsSql.GetAllForeignKeysConstraintsOfTable.sql
Last active Jul 18, 2019
Two sql statements to get all Foreign Keys from Table
View MsSql.GetAllForeignKeysConstraintsOfTable.sql
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.DeleteShpCorruptedList.ps1
Created Jul 18, 2019
Delete a corrupted SharePoint list
View Shp.DeleteShpCorruptedList.ps1
##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 / Shp.RedefineMasterPage.ps1
Created Jul 18, 2019
Redefine Site Master Page to Seattle (the original SharePoint MasterPage)
View Shp.RedefineMasterPage.ps1
##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 / MailSender.cs
Created Jul 18, 2020
Class with complete and stable structures for sending e-mail
View MailSender.cs
/// <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 / BenchmarkExtension.cs
Created Jul 21, 2020
Simple benchmark class extension
View BenchmarkExtension.cs
/// <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",
You can’t perform that action at this time.