Skip to content

Instantly share code, notes, and snippets.

View rdemorais's full-sized avatar
🏠
Working from home

Rafael de Morais rdemorais

🏠
Working from home
View GitHub Profile
@rdemorais
rdemorais / HsqlDbVis
Created March 19, 2016 22:08
HSQLDB Visualizer
import org.hsqldb.util.DatabaseManagerSwing;
//goes on test method
DatabaseManagerSwing.main(new String[] { "--url", "jdbc:hsqldb:mem:dataSource", "--user", "sa", "--password", "" });
@rdemorais
rdemorais / change_java_version_mac.txt
Created April 21, 2016 01:12
Change java version on mac
/usr/libexec/java_home -V
export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_75`
java -version
package br.com.entregaurbana.test.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle;
@rdemorais
rdemorais / Jpa_Schema_generator.txt
Last active February 8, 2017 18:25
JPA Schema generator
persistence.xml
<property name="javax.persistence.schema-generation.database.action" value="create"/>
<property name="javax.persistence.schema-generation.scripts.action" value="create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value="create.ddl"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/db"/>
Java class
@rdemorais
rdemorais / psql.txt
Created May 28, 2017 15:49
Execute PSQL in background for large files
nohup psql -d mydb -f insert.sql > insert.log 2>&1 &
@rdemorais
rdemorais / rename_timestamps.js
Created June 19, 2017 13:35
Rename timestamp sequelize
module.exports = function (sequelize, DataTypes) {
var AlunoCaso = sequelize.define('AlunoCaso', {
dtCriacao: {type: DataTypes.DATEONLY, allowNull: false, field: 'dt_cricao'},
dtAtualizacao: {type: DataTypes.DATEONLY, allowNull: false, field: 'dt_atualizacao'}
},
{
createdAt: 'dtCriacao',
updatedAt: 'dtAtualizacao',
timestamps: true,
tableName: 'tb_syn_aluno_caso'
@rdemorais
rdemorais / rawAttributes.js
Created June 19, 2017 14:54
raw Attributes sequelize
console.log(Object.keys(location.rawAttributes));
@rdemorais
rdemorais / import_restore_mongo
Last active August 1, 2017 19:46
Importar dados Mongo
mongoimport -d akulaapi -c bancos --type csv --file bancos.csv --headerline
mongodump --db test --collection collection
mongorestore --collection people --db accounts dump/
@rdemorais
rdemorais / create-participant.js
Created April 9, 2018 14:59
Hyperlegder Fabric - Composer - Create participant
async function teste() {
var namespace = 'br.com.synapsetec';
var producerType = 'Producer';
var producerNS = namespace + '.' + producerType;
const AdminConnection = require('composer-admin').AdminConnection;
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
const cardStore = require('composer-common').NetworkCardStoreManager.getCardStore();
const { IdCard } = require('composer-common');
businessNetworkConnection = new BusinessNetworkConnection({ cardStore: cardStore });
@rdemorais
rdemorais / timezone_dockerfile
Created May 8, 2018 20:39
Timezone dockerfile
RUN echo "America/Sao_Paulo" > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata