Skip to content

Instantly share code, notes, and snippets.

View SergioDiniz's full-sized avatar
🎮
Playing something 😋

Sergio SergioDiniz

🎮
Playing something 😋
  • João Pessoa, PB, Brazil
View GitHub Profile
@SergioDiniz
SergioDiniz / hibernate.cfg.xml
Created November 18, 2016 21:58
hibernate.cfg.xml for PostgreSQL
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
package dao;
import java.util.List;
import javax.persistence.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="persistenceUnitName" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->
@SergioDiniz
SergioDiniz / iReport config para JDK 7
Last active November 19, 2016 11:31
configuração necessária para iReport em maquinas com JAVA 8
#
# conf path: Applications/iReport/Contents/Resources/ireportpro/etc/ireportpro.conf
#
# ${HOME} will be replaced by user home directory according to platform
default_userdir="${HOME}/.${APPNAME}/5.6.0"
default_mac_userdir="${HOME}/Library/Application Support/${APPNAME}/5.6.0"
# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="-J-Xms256m -J-Xmx512m -J-Dorg.netbeans.ProxyClassLoader.level=1000 -J-XX:MaxPermSize=512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dnetbeans.exception.report.min.level=99999 "
private JasperPrint jasperPrint;
public void init() throws JRException{
JRBeanCollectionDataSource data = new JRBeanCollectionDataSource(listOfUser);
String reportPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(“report.jasper”);
jasperPrint = JasperFillManager.fillReport(reportPath, new HashMap<>(), data);
}
public void PDF() throws JRException, IOException{
init();
# precisa configura o connection pool e o resource manualmento no eclipse
# propriedades obrigatorias: DriverClass (org.postgresql.Driver), URL(jdbc:postgresql://localhost:5432/usuario), User, DatabaseName, ServerName, PortNumber, Password
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="jdbc/Usuario" transaction-type="JTA">
<jta-data-source>jdbc/Usuario</jta-data-source>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create" />
@SergioDiniz
SergioDiniz / staticServer.js
Created July 21, 2017 17:06
servidor estático nodejs
const PORT = 8080
const http = require('http');
const finalhandler = require('finalhandler');
const serveStatic = require('serve-static');
const serve = serveStatic("./app/");
const server = http.createServer((req, res) => {
const done = finalhandler(req, res);
rm $HOME/.RubyMine2016.2/config/eval/RubyMine162.evaluation.key
@SergioDiniz
SergioDiniz / Validador CPF.js
Last active November 9, 2019 12:18
Validador CPF
function validadorCPF(query = ""){
var primeiroDigitoValidador;
var segundoDigitoValidador;
var auxSoma = 0;
if( query === "00000000000"
|| query === "11111111111"
|| query === "22222222222"
|| query === "33333333333"
@SergioDiniz
SergioDiniz / docker-compose-pgadmin.yml
Last active September 6, 2023 09:47
Docker Compose config to postgres and dpage/pgadmin4
version: '3.5'
services:
postgres:
container_name: postgres_container
image: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-app_db}