Skip to content

Instantly share code, notes, and snippets.

View pedrovasconcellos's full-sized avatar

Pedro Vasconcellos pedrovasconcellos

View GitHub Profile
@pedrovasconcellos
pedrovasconcellos / Dockerfile
Created August 22, 2024 21:47
DockerFile App Java
# Use a base image com Java 11
FROM openjdk:11-jdk-slim
# Define o mantenedor do Dockerfile
LABEL maintainer="pedro@vasconcellos.solutions"
# Atualiza os pacotes e instala o Maven
RUN apt-get update && apt-get install -y maven
# Cria um diretório para a aplicação
@pedrovasconcellos
pedrovasconcellos / ide-shortcuts.txt
Last active August 8, 2024 18:53
IDE shortcuts for MacOS
------------------------------------------------------------------------------------------------------------------
VS-CODE
Depuração:
Step Over: F10
Step Into: F11
Step Out: Shift + F11
Resume Program: F5
Pause Program: F6
@pedrovasconcellos
pedrovasconcellos / launch.json
Created July 16, 2024 19:02
Enable Typescript debug mode in vscode
{
"version": "0.2.0",
"configurations": [
{
"args": [],
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "development"
},
"name": "DEBUG",
@pedrovasconcellos
pedrovasconcellos / Utilities.ts
Last active August 22, 2024 21:43
Utilities TypeScript
class Utilities {
public static isValidStringHeaders(headers: string): boolean {
const regex = /^[a-zA-Z0-9,_]+$/;
return regex.test(headers);
}
public static isValidStringHeaders(headers: string): boolean {
const allowedCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_,';
for (let i = 0; i < headers.length; i++) {
@pedrovasconcellos
pedrovasconcellos / ResultT.ts
Created October 23, 2023 11:37
Result T in TypeScript
type StringMap = Map<string, string>;
export class ResultT<T> {
value: T | null;
errors: StringMap;
constructor() {
this.value = null;
this.errors = new Map<string, string>();
}
@pedrovasconcellos
pedrovasconcellos / getCurlFromHttpClient.cs
Created June 2, 2023 01:59
get Curl From HttpClient
public void Print(HttpClient httpClient){
var jsonContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"curl -X {httpClient.HttpRequestMessage.Method} \"{url}\" \\\n" +
$"{GetHeadersAsString(httpClient.HttpRequestMessage.Headers)} \\\n" +
$"-d \"{jsonContent}\"");
}
static string GetHeadersAsString(HttpHeaders headers)
{
@pedrovasconcellos
pedrovasconcellos / ChecksForThePresenceOfDirectory.bash
Last active May 5, 2023 02:01
Remove duplicates of environment variable PATH
#Checks for the presence of directory /usr/local/go/bin in $PATH.
echo "$PATH" | grep -q -E "(^|:)/usr/local/go/bin($|:)"
is_present=$?
if [ $is_present -eq 1 ]; then
export PATH=$PATH:/usr/local/go/bin
echo "add go bin"
fi
@pedrovasconcellos
pedrovasconcellos / ResultT.go
Created April 28, 2023 20:19
Result class in Go Language
type ResultT struct {
Response interface{}
Errors map[string]string
}
func NewResultT() ResultT {
return ResultT{
Response: nil,
Errors: make(map[string]string),
}
@pedrovasconcellos
pedrovasconcellos / ResultT.rs
Last active April 28, 2023 20:15
Result class in Rust Language
use std::collections::HashMap;
pub struct ResultT<T> {
response: Option<T>,
errors: HashMap<String, String>,
}
impl<T> ResultT<T> {
pub fn new() -> Self {
ResultT {
@pedrovasconcellos
pedrovasconcellos / EnumExtensions.cs
Last active June 7, 2023 17:38
InvalidToDefaultEnumConverter
public static class EnumExtensions
{
public static T? GetDefaultValue<T>() where T : Enum
{
var enumType = typeof(T);
var defaultValueAttribute = Attribute
.GetCustomAttribute(enumType, typeof(DefaultValueAttribute)) as DefaultValueAttribute;
if (defaultValueAttribute is not null &&
defaultValueAttribute.Value is T)