Skip to content

Instantly share code, notes, and snippets.

View paulgrimaldo's full-sized avatar

Paul Fernando Grimaldo Bravo paulgrimaldo

View GitHub Profile
@paulgrimaldo
paulgrimaldo / MapStructExample.kotlin
Last active March 1, 2022 16:14
MapStruct mapping field to another type using named
@Mapper(
componentModel = "spring",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
unmappedTargetPolicy = ReportingPolicy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS
)
abstract class ClientMapper {
@Mappings(
Mapping(source = "type", target = "type"),
@paulgrimaldo
paulgrimaldo / gist:83cb7612d3374f875508f7396edb22b3
Created November 17, 2020 19:35 — forked from liweinan/gist:2622424
RESTEasy Code Reading
# Two different startup procedure
The one is to use ConfigurationBootstrap.
The other one is to use javax.ws.rs.Application as servlet name.
TODO: add more informations/code details on it.
# Startup Procedure
@paulgrimaldo
paulgrimaldo / Utils.kt
Created August 5, 2020 21:17
Kotlin helper for Mockito
fun <T> any(type: Class<T>): T {
Mockito.any(type)
return uninitialized()
}
@Suppress("UNCHECKED_CAST")
private fun <T> uninitialized(): T = null as T
/**
* Returns Mockito.eq() as nullable type to avoid java.lang.IllegalStateException when
@paulgrimaldo
paulgrimaldo / PathUtil.java
Created May 13, 2020 22:13
Get real path from Uri
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
Verificar los vhosts en nginx y en apache2 /etc/apache2/ & /etc/nginx
Crear la configuracion de vhstos para apuntar a proyecto correspondiente.
Importante activar y desactivar los sites https://www.linode.com/community/questions/311/how-do-i-enabledisable-a-website-hosted-with-apache
Generar el ssl con certbot.
En la configuracion del vhost anexar la ruta al certificado y la llave privada
(Si no puede conectar con letsencrypt entonces cambiar la configuracion DNS y usar la DNS de google /etc/resolv.conf)
Si el proyecto da error 404 en las rutas principales cambiar en la configuracion de apache /etc/apache2/apache2.conf por
<Directory "/var/www/html">
...
AllowOverride All
@paulgrimaldo
paulgrimaldo / es.dic
Created February 6, 2020 04:14
Dic for spanish language, you can install it in jetbrains products (intellij, webstorm, phpstorm, etc)
This file has been truncated, but you can view the full file.
a
b
c
d
e
f
g
h
i
j
@paulgrimaldo
paulgrimaldo / angular_jquery_components.txt
Created December 11, 2019 16:15
JQuery in AngularComponents
In components where we need to use jquery declare jquery or $ as any var.
//Top of *.component.ts
declare var jQuery: any
declare var $: any
//In index file (entry point)
add jquery CDN normally.
@paulgrimaldo
paulgrimaldo / angular_to_producction.txt
Created December 11, 2019 16:12
Angular projecto to producction
1.- Generate build version: ng build --prod
2.- Copy to host directory
3.- Change base url (if we are in a subdirectory)
4.- Add .htaccess (if we are in a subdirectory)
.htaccess =
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /client/
In composer.json add "tymon/jwt-auth": "dev-develop" in require section
then run composer update
if laravel version's <5.4 add provider Tymon\JWTAuth\Providers\LaravelServiceProvider::class
then publish the configuration
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
finally generate private key php artisan jwt:secret
@paulgrimaldo
paulgrimaldo / applicacion.properties.example
Created May 26, 2019 01:04
Application Properties for SpringBoot application with MysqlDataSource
spring.jpa.hibernate.ddl-auto=update
server.port=6666
spring.datasource.url=jdbc:mysql://localhost:3306/my-database?serverTimezone=America/Caracas
#spring.datasource.url=jdbc:mysql://localhost:3306/my-database
spring.datasource.username=root
spring.datasource.password=
spring.datasource.validationQuery=SELECT 1
spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect