Skip to content

Instantly share code, notes, and snippets.

View disouzam's full-sized avatar
🚲

Dickson Souza disouzam

🚲
View GitHub Profile
from collections import defaultdict
from graphlib import TopologicalSorter
from heapq import heappush, heappop, heapify
def topo_lex(pairs):
deps = defaultdict(set) # node -> set(dependencies)
for a, b in pairs:
deps.setdefault(a, set())
deps[b].add(a)
@disouzam
disouzam / servidores_nivel_superior.sql
Created April 11, 2025 18:03 — forked from fernandobarbalho/servidores_nivel_superior.sql
Busca a proporção de servidores com nível superior para os municípios brasileiros usando dados da RAIS
# Os dados estão presentes no repositório big query da base dos dados
SELECT id_municipio,
count(*) as quantidade_nivel_superior,
( select count(*)
from `basedosdados.br_me_rais.microdados_vinculos` vinc_sub
where vinc_sub.id_municipio = vinc.id_municipio and
ano = 2023 and
vinculo_ativo_3112 ="1" and
natureza_juridica = "1244") as total_servidores_municipio, #1244= município
@disouzam
disouzam / AddRating.cs
Created November 15, 2024 19:55 — forked from bradygaster/AddRating.cs
Contoso Crafts
public void AddRating(string productId, int rating)
{
var products = GetProducts();
var query = products.First(x => x.Id == productId);
if(query.Ratings == null)
{
query.Ratings = new int[] { rating };
}
else
@disouzam
disouzam / all_email_provider_domains.txt
Created November 11, 2024 19:52 — forked from ammarshah/all_email_provider_domains.txt
A list of all email provider domains (free, paid, blacklist etc). Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
0-mail.com
007addict.com
020.co.uk
027168.com
0815.ru
0815.su
0clickemail.com
0sg.net
0wnd.net
0wnd.org
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace FileAnalyzer
{
public class Record
{
public DateTime Start => DateTime.Parse(_line.Split(' ')[0]);
@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'
)