Skip to content

Instantly share code, notes, and snippets.

View disouzam's full-sized avatar
🚲

Dickson Souza disouzam

🚲
View GitHub Profile
# Long command with many parameters all on one line
Send-MailMessage -From "admin@example.com" -To "user@example.com" -Subject "Test Email" -Body "This is a test email." -SmtpServer "smtp.example.com" -Port 587 -UseSsl -Credential (Get-Credential) -Attachments "C:\path\to\file.txt" -Priority High -DeliveryNotificationOption OnSuccess, OnFailure
# Equivalent command using splatting for readability
$mailParams = @{
From = "admin@example.com"
To = "user@example.com"
Subject = "Test Email"
Body = "This is a test email."
SmtpServer = "smtp.example.com"
@disouzam
disouzam / AddColumnIfNotExists.sql
Created May 7, 2024 17:21 — forked from davepcallan/AddColumnIfNotExists.sql
Add created_date column to all tables which don't have it already in SQL Server
SELECT 'ALTER TABLE ' + QUOTENAME(ss.name) + '.' + QUOTENAME(st.name) + ' ADD created_date DATETIME NULL;'
FROM sys.tables st
INNER JOIN sys.schemas ss on st.[schema_id] = ss.[schema_id]
WHERE st.is_ms_shipped = 0
AND NOT EXISTS (
SELECT 1
FROM sys.columns sc
WHERE sc.[object_id] = st.[object_id]
AND sc.name = 'created_date'
)
@disouzam
disouzam / better-git-branch.sh
Created February 14, 2024 12:21 — forked from schacon/better-git-branch.sh
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@disouzam
disouzam / bash-template.sh
Last active February 11, 2024 16:42
Header of bash script to log commands and line number
#!/bin/bash
set -o xtrace
PS4='${LINENO}: '
@disouzam
disouzam / .editorconfig
Created January 29, 2024 10:25 — forked from MelbourneDeveloper/.editorconfig
Directory.Build.props Enable All Errors
[*.{cs,vb}]
dotnet_diagnostic.CA1062.severity = none
# IDE0022: Use block body for method
csharp_style_expression_bodied_methods = true
# IDE0032: Use auto property
dotnet_style_prefer_auto_properties = true
#CSharpier Incompatible Rules
@disouzam
disouzam / palestrasg.md
Created January 29, 2024 01:12 — forked from giggio/palestrasg.md
Links da palestra sobre Roslyn Source Generators
<PropertyGroup>
<PathMap>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))=./</PathMap>
</PropertyGroup>
@disouzam
disouzam / counting-files.sh
Created October 29, 2023 22:56
Counting files with a given word using bash
#! /bin/bash
file=./folder1/folder2/file-name-input.txt
outputfile=./folder1/folder2/file-name-output.txt
while IFS= read -r cmd; do
NUMBER_OF_FILES=$(grep --include=\*{ts,tsx} -rl './folder1' -e "$cmd" | wc -l)
printf 'Number of ocurrences: %s - Key: %s\n' "$NUMBER_OF_FILES" "$cmd" >> $outputfile
@disouzam
disouzam / .bashrc
Last active October 29, 2023 23:01
Bash configuration
alias cls=clear
alias dangcom='git fsck --no-progress --no-reflogs | grep '\''dangling commit'\'''
# alias dangcom='gitk --all --date-order '$(git fsck --no-progress --no-reflogs | \grep 'dangling commit' | \gawk '{printf $3; printf " "}')''
alias uptag='git show-ref --tags -s -d | grep 'refs' > list-of-tags.txt'
@disouzam
disouzam / AutoStopWatch.cs
Created October 10, 2023 01:05
File with two classes that implement StopWatches
// Reference:
// https://stackoverflow.com/questions/3903222/measure-execution-time-in-c-sharp
// Answer by https://stackoverflow.com/users/435383/katbyte
using System;
using System.Diagnostics;
using System.Threading;
namespace Diagnostic
{