This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.zup.edu.app2.xxx.samples.aws.sqs; | |
import br.com.zup.edu.app2.xxx.samples.aws.sqs.model.Customer; | |
import br.com.zup.edu.app2.xxx.samples.aws.sqs.model.CustomerRepository; | |
import io.awspring.cloud.messaging.listener.SqsMessageDeletionPolicy; | |
import io.awspring.cloud.messaging.listener.annotation.SqsListener; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |
import org.springframework.messaging.handler.annotation.Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Application configuration | |
## | |
samples.aws.sqs.consumer-queue: customersCreatedQueue | |
## | |
# Spring Cloud AWS | |
## | |
cloud: | |
aws: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.LoggerFactory | |
import org.springframework.jdbc.core.JdbcTemplate | |
import org.springframework.stereotype.Component | |
import org.springframework.transaction.annotation.Propagation | |
import org.springframework.transaction.annotation.Transactional | |
import java.time.Duration | |
interface LockManager { | |
fun <T> tryWithLock(key: Long, timeout: Duration, function: () -> T): T | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class NaiveJavaSynchronizedATMService { | |
@Autowired | |
private AccountRepository repository; | |
@Transactional | |
public synchronized void withdraw(Long accountId, double amount) { | |
Account account = repository.findById(accountId).orElseThrow(() -> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard HEAD ; git clean -fd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Trying to buy a new ticket for an event | |
-- | |
BEGIN; | |
UPDATE events e | |
SET updated_at = now() | |
WHERE e.id = :event_id | |
AND e.max_tickets > (SELECT count(*) -- (does this logic work with READ_COMMITTED??) | |
FROM tickets t | |
WHERE t.event_id = e.id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.zup.edu.livraria; | |
import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcBuilderCustomizer; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.core.authority.SimpleGrantedAuthority; | |
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; | |
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | |
import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder; | |
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.zup.edu.minhasfigurinhas; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
import static org.springframework.http.HttpMethod.GET; | |
import static org.springframework.http.HttpMethod.POST; | |
import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Album { | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
private Long id; | |
@Size(min = 1) | |
@OneToMany(cascade = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 1. run theses commands on PowerShell as admin | |
# 2. restart windows | |
## | |
wsl --shutdown | |
netsh winsock reset | |
netsh int ip reset all | |
netsh winhttp reset proxy | |
ipconfig /flushdns |