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 / AwsSdkV2AndVirtualThreads.java
Created October 25, 2024 01:01 — forked from marcogrcr/AwsSdkV2AndVirtualThreads.java
Java AWS SDK v2 and virtual threads
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@andysteel
andysteel / postgres_queries_and_commands.sql
Created December 19, 2023 18:42 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@andysteel
andysteel / nvmCommands.js
Created December 6, 2022 22:06 — forked from chranderson/nvmCommands.js
Useful NVM commands
// check version
node -v || node --version
// list installed versions of node (via nvm)
nvm ls
// install specific version of node
nvm install 6.9.2
// set default version of node
@andysteel
andysteel / CustomExceptionControllerAdvice.java
Created May 10, 2022 00:24 — forked from susimsek/CustomExceptionControllerAdvice.java
Spring Boot File Content Type Validation With Annotation
@ControllerAdvice
public class CustomExceptionControllerAdvice {
@ExceptionHandler(MultipartException.class)
void handleMultipartException(MultipartException ex,HttpServletResponse response) throws IOException {
response.sendError(HttpStatus.BAD_REQUEST.value(),"Please select a file");
}
@ExceptionHandler(ConstraintViolationException.class)
public void handleConstraintViolationException(ConstraintViolationException ex,HttpServletResponse response) throws IOException {
@andysteel
andysteel / OracleOpenPort80Centos.md
Created May 13, 2021 02:27 — forked from jbaranski/OracleOpenPort80Centos.md
Open Port 80 Oracle Cloud Compute Instance (CentOS)

Open Port 80 Oracle Cloud Compute Instance (CentOS)

FYI This was harder than it needed to be:

  1. Looking at your instance info, find VNIC section, click "Public Subnet".
  2. Click on your security list.
  3. Add a new entry with the following options:
  • "Stateless" = No, "Source" = 0.0.0.0/0, "IP Protocol" = TCP, "Source Port Range" = All, "Destination Port Range" = 80
  1. SSH to your instance.
  2. While SSH'ed in your instance, run command firewall-cmd --permanent --add-service=http.
  3. While SSH'ed in your instance, run command firewall-cmd --reload.
  4. Now start Apache, NGINX, or whatever server you need to on port 80. You can now access from the internet.
@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 / GitCommitEmoji.md
Created January 20, 2021 20:41 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji