Skip to content

Instantly share code, notes, and snippets.

View jogaco's full-sized avatar
🎯
Focusing

J. Garcia jogaco

🎯
Focusing
View GitHub Profile
@jogaco
jogaco / console_output_3.txt
Created May 21, 2017 18:21
Spring Boot Tutorial: first Repository test is passing
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2017-05-21 20:14:25.542 INFO 9085 --- [ main] c.o.g.SpringBootMysqlApplicationTests : Starting SpringBootMysqlApplicationTests on hal9003 with PID 9085 (started by jgarcia in /home/java-projects/spr-boot)
2017-05-21 20:14:25.544 INFO 9085 --- [ main] c.o.g.SpringBootMysqlApplicationTests : No active profile set, falling back to default profiles: default
mysql -h $1 -e "create database $3 CHARACTER SET $character_set"
TRIGGERS=`mysql -h $1 $2 -e "show triggersG" | grep Trigger: | awk '{print $2}'`
VIEWS=`mysql -h $1 -e "select TABLE_NAME from information_schema.tables where table_schema='$2' and TABLE_TYPE='VIEW'" -sss`
if [ -n "$VIEWS" ]; then
mysqldump -h $1 $2 $VIEWS > /tmp/${2}_views${TIMESTAMP}.dump
fi
mysqldump -h $1 $2 -d -t -R -E > /tmp/${2}_triggers${TIMESTAMP}.dump
for TRIGGER in $TRIGGERS; do
echo "drop trigger $TRIGGER"
mysql -h $1 $2 -e "drop trigger $TRIGGER"
@jogaco
jogaco / self-signed-certificate-with-custom-ca.md
Created October 25, 2018 13:06 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@jogaco
jogaco / update-cloudflare-ips.sh
Created May 15, 2017 15:28
Cloudflare: automatic update of IP addresses
#!/bin/bash
# Location of the nginx config file that contains the CloudFlare IP addresses.
CF_NGINX_CONFIG="/etc/nginx/cloudflare-real-ip.conf"
CF_NGINX_CONFIG_NEW="/etc/nginx/cloudflare-real-ip.conf.new"
# The URLs with the actual IP addresses used by CloudFlare.
CF_URL_IP4="https://www.cloudflare.com/ips-v4"
CF_URL_IP6="https://www.cloudflare.com/ips-v6"
@jogaco
jogaco / BasicAuthAuthorizationInterceptor.java
Last active August 28, 2017 10:44
Java REST Web Service securization for Apache CXF 2.3.3 with Spring Security 3.0.5: Basic Authentication
import javax.ws.rs.core.Response;
import org.apache.cxf.configuration.security.AuthorizationPolicy;
import org.apache.cxf.interceptor.security.AccessDeniedException;
import org.apache.cxf.jaxrs.ext.RequestHandler;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.message.Message;
import org.apache.log4j.Logger;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.encoding.PasswordEncoder;
@jogaco
jogaco / console_output_2.txt
Created May 21, 2017 18:18
Spring Boot Tutorial: hibernate-maven-plugin created tables and schema file
--- hibernate-maven-plugin:2.0.0:drop (default) @ spring-boot-mysql ---
[INFO] HHH000318: Could not find any META-INF/persistence.xml file in the classpath
[INFO] Found no META-INF/persistence.xml.
[INFO] Gathered hibernate-configuration (turn on debugging for details):
[INFO] hibernate.connection.username = username
[INFO] hibernate.connection.password = password
[INFO] hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
[INFO] hibernate.connection.url = jdbc:mysql://localhost/game_manager?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
[INFO] hibernate.hbm2dll.create_namespaces = false
[INFO] hibernate.connection.driver_class = com.mysql.jdbc.Driver
@jogaco
jogaco / pom.xml
Last active May 21, 2017 18:13
Spring Boot Tutorial: adding hibernate-maven-plugin
...
<build>
<plugins>
...
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
@jogaco
jogaco / hibernate.properties
Created May 21, 2017 18:09
Spring Boot Tutorial: hibernate.properties
# https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html
# Must use @...@ instead of ${...}
hibernate.dialect=@hibernate.dialect@
# Needed by Hibernate3 Maven Plugin defined in pom.xml
hibernate.connection.username= @jdbc.username@
hibernate.connection.password=@jdbc.password@
hibernate.connection.url=@jdbc.url@
hibernate.connection.driver_class=@jdbc.driverClassName@
@jogaco
jogaco / console_output_1.txt
Created May 21, 2017 17:51
Spring Boot Tutorial: build failure as we have no tables to insert dbunit data
[INFO] --- dbunit-maven-plugin:1.0-beta-3:operation (test-compile) @ spring-boot-mysql ---
78 [main] INFO org.dbunit.database.DatabaseDataSet -
database name=MySQL
database version=5.6.36-82.0
database major version=5
database minor version=6
jdbc driver name=MySQL Connector Java
jdbc driver version=mysql-connector-java-5.1.35 ( Revision: 5fb9c5849535c13917c2cf9baaece6ef9693ef27 )
jdbc driver major version=5
jdbc driver minor version=1
@jogaco
jogaco / SpringBootMySqlApplicationTests.java
Created May 21, 2017 17:46
Spring Boot Tutorial: tests
package com.operatornew.gamemanager;
import com.operatornew.gamemanager.domain.Game;
import com.operatornew.gamemanager.repository.GameRepository;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;