Skip to content

Instantly share code, notes, and snippets.

View albertocavalcante's full-sized avatar
🌎
BRA -> USA

Alberto Cavalcante albertocavalcante

🌎
BRA -> USA
View GitHub Profile
@titobundy
titobundy / copilot-instructions.md
Last active May 15, 2025 06:54 — forked from burkeholland/copilot-instructions.md
Custom Instructions Example

Vite / React / Tailwind / Nanostores / Astro Best Practices

This guide outlines best practices for building a Vite / React / Tailwind / Nanostores / Astro application. The goal is readability and maintainability, minimizing abstraction to keep the codebase clear.

Tech Stack Overview

  • Astro
  • Preact
  • Nanostores
  • Tailwind CSS
  • Postgres
@digitarald
digitarald / mcp.json
Last active May 4, 2025 08:32
MCP Template for VS Code GitHub Copilot
{
"inputs": [
{
"type": "promptString",
"id": "github-pat",
"password": true,
"description": "GitHub Personal Access Token (PAT, https://github.com/settings/personal-access-tokens/new)"
}
],
"servers": {
@iamarcel
iamarcel / search-gpt.py
Created February 11, 2023 12:57
Basic GPT-3 + Bing Answering Machine
import os
import openai
import requests
from pprint import pprint
import dotenv
dotenv.load_dotenv()
openai_api_key = os.environ.get("OPENAI_API_KEY")
bing_search_api_key = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
package main
import (
"bufio"
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
@wilsonfreitas
wilsonfreitas / rb3-indexes-donuts.R
Created May 30, 2022 10:47
Indexes Composition in a Donuts Plot
library(rb3)
library(tidyverse)
top_weight <- function(.data, n = 10) {
top_10 <- .data |>
arrange(desc(weight)) |>
slice_head(n = n) |>
select(symbol, weight)
total_weight <- sum(top_10$weight)
others <- tibble(
@rponte
rponte / BeanValidationConfig.java
Last active December 27, 2021 20:33
Spring Boot: integrating Bean Validation between Spring and Hibernate (supporting DI on custom validations with Hibernate)
@Configuration
public class BeanValidationConfig {
/**
* The idea here is to configure Hibernate to use the same ValidatorFactory used by Spring,
* so that Hibernate will be able to handle custom validations that need to use dependency injection (DI)
*/
@Bean
public HibernatePropertiesCustomizer hibernatePropertiesCustomizer(final Validator validator) {
return new HibernatePropertiesCustomizer() {
@tokrug
tokrug / ConditionalOnConfigurationProperties.java
Last active January 21, 2024 00:20
Spring Boot autoconfiguration conditional annotation on typesafe ConfigurationProperies class. Maps properties to the provided class and executes it's isPresent() method to determine if Conditional should match or not. application.yml, ExampleSpringConfiguration.java and ExampleSpringPropertiesModel.java show how the rest of the code can be used.
/**
* Metannotation for OnConfigurationPropertiesCondition custom conditional implementation.
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Conditional(OnConfigurationPropertiesCondition.class)
public @interface ConditionalOnConfigurationProperties {
// properties namespace
@moscas
moscas / Sum.groovy
Created December 8, 2020 13:38
Data extractor for IntelliJ which counts the sum of numeric values
/*
* Available context bindings:
* COLUMNS List<DataColumn>
* ROWS Iterable<DataRow>
* OUT { append() }
* FORMATTER { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); }
* TRANSPOSED Boolean
* plus ALL_COLUMNS, TABLE, DIALECT
*
* where:
@daehahn
daehahn / wsl2-network.ps1
Last active April 21, 2025 03:30
WSL 2 TCP NETWORK FORWARDING
# WSL2 network port forwarding script v1
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell,
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter.
# written by Daehyuk Ahn, Aug-1-2020
# Display all portproxy information
If ($Args[0] -eq "list") {
netsh interface portproxy show v4tov4;
exit;
}
@jamescalam
jamescalam / smtp_example.py
Created May 26, 2020 16:53
Example code for sending an email via SMTP with TLS encryption in Python.
import smtplib
# initialize connection to our email server, we will use Outlook here
smtp = smtplib.SMTP('smtp-mail.outlook.com', port='587')
smtp.ehlo() # send the extended hello to our server
smtp.starttls() # tell server we want to communicate with TLS encryption
smtp.login('[email protected]', 'Password123') # login to our email server