Skip to content

Instantly share code, notes, and snippets.

@edubriguenti
edubriguenti / jpaNativeQuerySample.kt
Created October 4, 2020 13:28 — forked from arseto/jpaNativeQuerySample.kt
JPA Native Query with Kotlin and Spring
@Service
class SalesOrderServiceImpl @Autowired constructor (
val em: EntityManager
) : SalesOrderService {
override fun getDailySalesData(reportFilter: ReportFilter)
: List<SalesData> {
val q = em.createNativeQuery("""
SELECT
s.date,
@edubriguenti
edubriguenti / gist:e51eb9db999c3a0bbcbd43c67e42c6fd
Created June 16, 2020 21:23
Security Implementation example
https://gitlab.com/aovs/projetos-cursos/fj27-alura-forum-api/tree/master/src/main/java/br/com/alura/forum/security
@edubriguenti
edubriguenti / JAXB_PARSE
Last active May 27, 2020 13:34
JAXB PARSE
public void toXml(UpdateRequest request) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(CreateResponse.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(request, sw);
String xmlContent = sw.toString();
System.out.println( xmlContent );
System.out.println( );
@edubriguenti
edubriguenti / selectionSort.cpp
Last active January 7, 2019 15:16
Selection_Sort
void selection_sort(){
for (int i = 0; i < 5; i++){
int menor = i;
for (int j = i; j < 5; j++){
if (notas[j] < notas[menor]){
menor = j;
}
}
swap(notas[menor], notas[i]);
@edubriguenti
edubriguenti / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@edubriguenti
edubriguenti / JSONP_call_URL_valid
Created October 9, 2014 14:49
Checks if an URL is valid via JSONP
<rich:modalPanel minwidth="300" minheight="100" id="mensagemURLModal"
modal="true" resizeable="false" autosized="true">
<table width="250" border="0" cellpadding="4" cellspacing="0" align="center">
<tr>
<td align="center">
<div id="mensagemURL"></div>
</td>
</tr>
<tr>
@edubriguenti
edubriguenti / Adiciona_CSS_JSF
Created September 30, 2014 19:21
Adicionar CSS em comopoenent no managedBean
private static void adicionarCss(final String id, final String css) {
final UIComponent component = getComponenteById(id);
if(component!=null){
if(component instanceof HtmlInputText){
final HtmlInputText input = ((HtmlInputText)component);
if(input.getStyleClass()==null){
input.setStyleClass(css);
}else{
input.setStyleClass(input.getStyleClass()+" "+css);
@edubriguenti
edubriguenti / springdata_keywords
Created September 27, 2014 23:24
Spring data - keywords
Table 2.2. Supported keywords inside method names
Keyword Sample JPQL snippet
And findByLastnameAndFirstname … where x.lastname = ?1 and x.firstname = ?2
Or findByLastnameOrFirstname … where x.lastname = ?1 or x.firstname = ?2
Between findByStartDateBetween … where x.startDate between 1? and ?2
LessThan findByAgeLessThan … where x.age < ?1
GreaterThan findByAgeGreaterThan … where x.age > ?1
After findByStartDateAfter … where x.startDate > ?1
Before findByStartDateBefore … where x.startDate < ?1
@edubriguenti
edubriguenti / spring-boot-properties
Last active July 9, 2023 05:29
Common spring boot properties
# ===================================================================
# COMMON SPRING BOOT PROPERTIES
#
# This sample file is provided as a guideline. Do NOT copy it in its
# entirety to your own application. ^^^
# ===================================================================
# ----------------------------------------
# CORE PROPERTIES
# ----------------------------------------
@edubriguenti
edubriguenti / Print Obj Attributes
Created September 8, 2014 13:39
Print the attibutes of an object
var output = '';
for (var property in obj) {
output += property + ': ' + obj[property]+'; ';
}
alert(output);