Skip to content

Instantly share code, notes, and snippets.

@rlcc885
rlcc885 / nowphptomysql.php
Created November 7, 2020 23:12
get now php to mysql
$date = date('Y-m-d H:i:s');
@rlcc885
rlcc885 / update-table-with-innerjoin-oracle.sql
Created October 6, 2020 23:00 — forked from arbo-hacker/update-table-with-innerjoin-oracle.sql
Actualizar tabla con inner join en ORACLE
UPDATE tabla1 t1
SET t1.valor = (SELECT t2.CODE FROM tabla2 t2 WHERE t1.valor = t2.DESC and t1.fecha=t2.fecha)
WHERE t1.filtro='correcto'
AND EXISTS (SELECT t2.CODE FROM tabla2 t2 WHERE t1.valor = t2.DESC and t1.fecha=t2.fecha);
-- O
UPDATE
(SELECT t1.valor  as OLD, t2.CODE as NEW
FROM tabla1 t1
@rlcc885
rlcc885 / SpecificationJoinTable.java
Created September 30, 2020 04:28
How to join external table in specification predicate builder
//...
if (criteria.getIdTipoComunicado() != null) {
Join<ComunicadoGrupo, Comunicado> comunicado = root.join("listComunicado");
Join<Comunicado, TipoComunicado> tipoComunicado = comunicado.join("tipoComunicado");
predicates.add(criteriaBuilder.equal(tipoComunicado.get("idTipoComunicado"), criteria.getIdTipoComunicado()));
}
//...
@rlcc885
rlcc885 / ReactiveFormReadOnlyInput.ts
Created September 17, 2020 20:54
Define as Read Only input (Angular)
//... ReadOnly // new FormControl({value: null, disabled: true}, Validators.required),
this.registerForm = this.formBuilder.group({
first_name: ['', Validators.required],
last_name: ['', Validators.required],
email: new FormControl({value: null, disabled: true}, Validators.required),
password: ['', Validators.compose([Validators.required, Validators.email])],
confirm_password: ['', Validators.required],
});
//... Get Values
this.registerForm.getRawValue();
@rlcc885
rlcc885 / LoadResourceInsideJar.java
Created September 10, 2020 06:05
Load Resource from inner folder (Spring boot)
public class LoadResourceInsideJar {
// ...
@PostConstruct
public void init() {
try {
Resource resource = resourceLoader.getResource("classpath:emailTemplate.html");
InputStream resourceAsStream = resource.getInputStream(); // <-- this is the difference (Jar Embedded)
} catch (IOException | NullPointerException e) {
LOGGER.error("Resource couldn't be loaded. ", e);
}
SCRIPT NODATA TO 'script.sql';
--spring.config.location=file:///E:/properties/nameapp-application.yml
--spring.config.location=file:///E:/properties/nameapp-application.properties
java -jar name-app.jar --spring.config.location=file:///C:/properties/application.yml
public class FormatDate {
private static CellStyle getFormatAsDate(Workbook workbook) {
CreationHelper creationHelper = workbook.getCreationHelper();
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("dddd dd/MM/yyyy hh:mm:ss"));
return cellStyle;
}
}
@rlcc885
rlcc885 / RestControllerExcel.java
Last active December 12, 2022 15:42
Spring boot REST Service - Apache POI force download excel
public class RestControllerExcel{
@GetMapping(value="/downloadTemplate")
public ResponseEntity<ByteArrayResource> downloadTemplate() throws Exception {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
XSSFWorkbook workbook = createWorkBook(); // creates the workbook
HttpHeaders header = new HttpHeaders();
header.setContentType(new MediaType("application", "force-download"));
header.set(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=ProductTemplate.xlsx");
workbook.write(stream);
<?php
require('vendor/autoload.php');
use \Firebase\JWT\JWT;
class ImplementJwt {
//////////The function generate token/////////////
PRIVATE $key = "uEsHptabPr3qIjjyFrOK2G7PMbh82Czi";
public function GenerateToken($data) {
$jwt = JWT::encode($data, $this->key);
return $jwt;