Skip to content

Instantly share code, notes, and snippets.

View andysteel's full-sized avatar
🏠
Working from home

Anderson Dias andysteel

🏠
Working from home
View GitHub Profile
@andysteel
andysteel / AuthContext.tsx
Created May 2, 2021 23:45
React with Typescript example to use context API for Auth Provider
import React from 'react';
interface AuthProps {
token: string | undefined;
setToken: React.Dispatch<React.SetStateAction<string | undefined>>;
}
const DEFAULT_VALUE: AuthProps = {
token: undefined,
setToken: () => {}
@andysteel
andysteel / comandos-docker.sh
Last active March 4, 2023 04:17
List of docker commands
#####################################
# #
# Comandos Docker #
#####################################
1- criar e executar um container e baixar uma imagem:
docker container run hello-world
*o comando run baixa uma imagem se ela não existir local, depois de baixada essa imagem só executa local, o comando run cria um container(sempre cria um novo) e também inicializa
@andysteel
andysteel / Cipher.java
Created April 25, 2021 05:35
Java encypt decrypt examples
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
public class Cipher {
private Cipher() {
}
/**
* Descriptografar uma string.
*/
@andysteel
andysteel / InicioComponent.ts
Created April 25, 2021 05:26
Angular Event emmiter example like a Service
import { Component, OnInit, OnDestroy, Output, EventEmitter} from '@angular/core';
import { MenuSateService } from '../shared/service/menu-state.service';
@Component({
selector: 'app-inicio',
templateUrl: './inicio.component.html',
styleUrls: ['./inicio.component.css']
})
export class InicioComponent implements OnInit, OnDestroy {
@andysteel
andysteel / Car.java
Created April 21, 2021 02:59
How to call Oracle Procedure with Spring and Hibernate
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;
@andysteel
andysteel / User.java
Created March 30, 2021 05:57
Validation with hibernate-validator 7 and jakarta EE
package com.gmail.andersoninfonet.testesgenericos.model;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
@andysteel
andysteel / CriteriaUtils.java
Created February 23, 2021 22:06 — forked from brunocribeiro/CriteriaUtils.java
Utility method to get SQL from Hibernate Criteria
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.Criteria;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CriteriaImpl;
import org.hibernate.internal.SessionImpl;
import org.hibernate.loader.OuterJoinLoader;
import org.hibernate.loader.criteria.CriteriaLoader;
import org.hibernate.persister.entity.OuterJoinLoadable;
@andysteel
andysteel / Regex.java
Created February 10, 2021 03:04
RegexTips and Java Examples
public class RegexExample {
public static void main(String[] args) {
//seacrhing all tags from a html in a string
//pure regex: /<\w+>|<\/\w+>/gm
//example in Java serching and removing all tags
String html = "<body><h1>Hello World</h1><p>Match Regex</p></body>";
html = html.replaceAll("<\\w+>|<\\/\\w+>","");
System.out.println(html);
@andysteel
andysteel / GitCommitEmoji.md
Created January 20, 2021 20:41 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
#Example of ~/.ssh/config
Host 192.168.0.1
HostName 192.168.0.1
User root
IdentityFile ~/.ssh/KeyPairOk.pem