Skip to content

Instantly share code, notes, and snippets.

View pydawan's full-sized avatar

Thiago Monteiro pydawan

View GitHub Profile
@rhamedy
rhamedy / README.md
Last active June 1, 2022 02:20
Configure HikariCP with Spring Boot JPA Hibernate and PostgreSQL as a database

I came across HikariCP and I was amazed by the benchmarks and I wanted to try it instead of my default choice C3P0 and to my surprise I struggled to get the configurations right probably because the configurations differ based on what combination of tech stack you are using.

I have setup Spring Boot project with JPA, Web, Security starters (Using [Spring Initializer][1]) to use PostgreSQL as a database with HikariCP as connection pooling.
I have used Gradle as build tool and I would like to share what worked for me for the following assumptions:

  1. Spring Boot Starter JPA (Web & Security - optional)
  2. Gradle build tool
  3. PostgreSQL running and setup with a database (i.e. schema, user, db)

This gist is related to SO post https://stackoverflow.com/questions/26490967/how-do-i-configure-hikaricp-in-my-spring-boot-app-in-my-application-properties-f

@ankurk91
ankurk91 / 1-elementary-os-apps.md
Last active October 1, 2025 14:53
elementary OS 5.1 Hera

elementaryOS Apps and Configs

⚠️ No longer maintained! ⚠️

This guide has been updated for elementaryOS v5.0+.

Enbale PPA support

sudo apt-get update
sudo apt-get -y install software-properties-common
@esilvajr
esilvajr / image_phpstorm_server.png
Last active November 12, 2024 04:17
How to use XDebug inside a docker container.
image_phpstorm_server.png
@paulofreitas
paulofreitas / security-http-headers.md
Last active June 11, 2021 16:22
Cabeçalhos de resposta HTTP relacionados a segurança

Content-Security-Policy, X-Content-Security-Policy, X-WebKit-CSP

O cabeçalho de resposta HTTP Content-Security-Policy permite aos administradores de sites controlar os recursos que o navegador ou agente de usuário (user agent) pode carregar em uma determinada página. Com algumas exceções, as políticas envolvem principalmente especificar as origens do servidor e os endpoints de script. Isso ajuda a proteger contra ataques de XSS.

O cabeçalho de respsota HTTP X-Content-Security-Policy é requerido para implementar o CSP no Internet Explorer 10 e 11.

O cabeçalho de resposta HTTTP X-Webkit-CSP é requerido para implementar o CSP em versões mais antigas do Google Chrome, Safari e outros navegadores baseados na engine WebKit.

Para navegadores modernos, o cabeçalho Content-Security-Policy deve ser usado.

@MichalZalecki
MichalZalecki / docx2pdf.py
Created July 8, 2017 08:09
Converting DOCX to PDF using Python
import sys
import subprocess
import re
def convert_to(folder, source, timeout=None):
args = [libreoffice_exec(), '--headless', '--convert-to', 'pdf', '--outdir', folder, source]
process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
filename = re.search('-> (.*?) using filter', process.stdout.decode())
@jahe
jahe / jpa-cheatsheet.java
Last active September 3, 2025 14:31
JPA Cheatsheet
/*
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger:
---
entityManager.getTransaction().begin();
entityManager.persist(<some-entity>);
entityManager.getTransaction().commit();
entityManager.clear();
@trandaison
trandaison / starUML.md
Last active September 30, 2025 16:12
Get full version of StarUML
@zcaceres
zcaceres / Include-in-Sequelize.md
Last active April 2, 2025 06:07
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

# One line install
echo -e "g\nn\n\n\n+100M\nt\n1\nn\n\n\n+1G\nn\n\n\n\n\nw\nq\n" | fdisk /dev/sda && mkfs.vfat -F32 /dev/sda1 && mkswap /dev/sda2 && mkfs.ext4 /dev/sda3 && swapon /dev/sda2 && mount /dev/sda3 /mnt && mkdir -p /mnt/{boot/efi,home} && mount /dev/sda1 /mnt/boot/efi && pacstrap /mnt base base-devel && genfstab -p /mnt >> /mnt/etc/fstab && echo -e "echo NomDeLaMachine > /etc/hostname && echo '127.0.1.1 NomDeLaMachine.localdomain NomDeLaMachine' >> /etc/hosts && rm -f /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo 'fr_FR.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen && echo 'LANG=fr_FR.UTF-8' > /etc/locale.conf && echo KEYMAP=fr > /etc/vconsole.conf && mkinitcpio -p linux" | arch-chroot /mnt && echo -e "pacman --noconfirm -Syu xorg-server xorg-xinit xorg-server-utils xf86-video-intel xf86-input-synaptics gdm gnome networkmanager terminator emacs atom gcc valgrind firefox chromium git openssh" | arch-chroot /mnt && echo -e "useradd -Nm -g users -G wheel,sys epitech_
@lorenzoongithub
lorenzoongithub / toString.js
Last active August 16, 2019 12:48
Object.toString alternative. A universal "toString" JavaScript function for any Java Object. Works on nashorn, nudge4j and can be called from Java 8
function toString(oj) {
if (oj == null) return 'null';
if (Java.isJavaObject(oj)==false) return 'Error: not a Java Object';
try {
java.lang.Class.forName('org.apache.commons.lang3.builder.ReflectionToStringBuilder');
} catch (e) {
var url = new java.net.URL('http://central.maven.org/maven2/org/apache/commons/commons-lang3/3.0/commons-lang3-3.0.jar');
var ucl = java.lang.Class.forName('java.net.URLClassLoader');
var addURL = ucl.getDeclaredMethod("addURL", [ url.getClass() ]);
addURL.setAccessible(true);