Skip to content

Instantly share code, notes, and snippets.

View disouzam's full-sized avatar
🚲

Dickson Souza disouzam

🚲
View GitHub Profile
@disouzam
disouzam / deactivate
Created August 12, 2024 21:02 — forked from karrtikr/deactivate
Script to deactivate virtual environments for bash or zsh
# >>> Virtual env deactivate hook >>>
# Same as deactivate in "<venv>/bin/activate"
deactivate () {
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
# Long command with many parameters all on one line
Send-MailMessage -From "[email protected]" -To "[email protected]" -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 = "[email protected]"
To = "[email protected]"
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 25, 2024 00:47
Bash configuration
# set -o xtrace
# https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
# Green 0;32 Light Green 1;32
# Cyan 0;36 Light Cyan 1;36
# Red 0;31 Light Red 1;31
# Purple 0;35 Light Purple 1;35
# Brown 0;33 Yellow 1;33