Skip to content

Instantly share code, notes, and snippets.

View ggdio's full-sized avatar
:octocat:
Learning something new

Guilherme Dio ggdio

:octocat:
Learning something new
View GitHub Profile
@ggdio
ggdio / column-search.sql
Last active December 23, 2015 06:59
DB Utilities
--SQLSERVER
SELECT
t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM
sys.tables AS t
INNER JOIN sys.columns c
ON t.OBJECT_ID = c.OBJECT_ID
WHERE
SQLSERVER
------------
SELECT
TABLE_NAME
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE = 'BASE TABLE' AND
TABLE_NAME LIKE '%TBL%';
--ORACLE
SELECT
*
FROM
ALL_CONSTRAINTS
WHERE
R_OWNER = 'NOME_OWNER'
AND R_CONSTRAINT_NAME IN
(SELECT
CONSTRAINT_NAME
--Create a .txt file
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
--Run the following command(OBS: replace the file_path)
%MYSQL_HOME%\bin\mysqld-nt --init-file=[FILE_PATH]
@ggdio
ggdio / log4j.properties
Last active December 23, 2015 07:09
Log4j Configuration
#Hierarchy TRACE < DEBUG < INFO < WARN < ERROR < FATAL
#Log - Console/Arquivo
log4j.rootCategory = DEBUG,console,arquivo
#CONSOLE(Log a partir de DEBUG)
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %d{HH:mm:ss} (%F:%L) %p - %m%n
@ggdio
ggdio / persistence.xml
Created September 17, 2013 19:16
JPA XML config
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="nomeDaPersistenceUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/database" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="usuario" />
<property name="hibernate.connection.password" value="senha" />
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<!--
Configuration file for UrlRewriteFilter
http://www.tuckey.org/urlrewrite/
-->
@ggdio
ggdio / web.xml
Created September 17, 2013 19:19
Default web.xml for java web app
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="NomeSistema"
version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>NomeSistema</display-name>
<servlet>
@ggdio
ggdio / ValidationMessages.properties
Created September 17, 2013 19:43
javax validation messages config file
javax.validation.constraints.AssertFalse.message=The value must be false
javax.validation.constraints.AssertTrue.message=The value must be true
javax.validation.constraints.DecimalMax.message=The value must be less or equal to {value}
javax.validation.constraints.DecimalMin.message=The value must be bigger or equal to {value}
javax.validation.constraints.Max.message=The value max length is {value}
javax.validation.constraints.Min.message=The value min length is {value}
javax.validation.constraints.NotNull.message=It must not be null
javax.validation.constraints.Size.message=The value must be between {min} and {max}
@ggdio
ggdio / .gitignore
Created September 17, 2013 19:46
Pre-configured git ignore file for java repos
*.class
# Package Files #
*.jar
*.war
*.ear
# Workspace Metadata #
.metadata/