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 / Game.java
Created May 21, 2017 16:37
Spring Boot Tutorial
package com.operatornew.gamemanager.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "game")
@jogaco
jogaco / application.properties
Created May 21, 2017 16:27
Spring Boot Tutorial
# Spring Boot: must use @..@ instead of ${...} https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html
spring.datasource.url=@jdbc.url@
spring.datasource.username=@jdbc.username@
spring.datasource.password=@jdbc.password@
spring.datasource.driver-class-name=@jdbc.driverClassName@
@jogaco
jogaco / pom.xml
Last active May 21, 2017 16:25
Spring Boot tutorial: pom.xml fragment: schema properties
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<db.name>game_manager</db.name>
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
<jdbc.url>jdbc:mysql://localhost/${db.name}?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC</jdbc.url>
<jdbc.username>username</jdbc.username>
<jdbc.password>password</jdbc.password>
</properties>
@jogaco
jogaco / pom.xml
Created May 21, 2017 15:40
Generated pom.xml for Spring Boot with JPA and MySql
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.operatornew</groupId>
<artifactId>spring-boot-mysql</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
@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"
class SitemapSettings
DEFAULT_HOST = 'http://www.example.com'
PUBLIC_PATH = 'private/'
SITEMAPS_PATH_NEW = 'sitemapsnew/'
SITEMAPS_PATH_PUBLISHED = 'sitemaps/'
DEFAULT_PRIORITY_MAP = [0.5]
end
@jogaco
jogaco / es_rolling_upgrade.sh
Created June 14, 2016 07:26
Script to install a rolling upgrade of ElasticSearch, for a single node setup. Checked in ubuntu
#!/bin/bash
display_usage() {
echo "This script must be run with super-user privileges."
echo -e "\nUsage:\n$0 [es-version e.g.: "2.3.3"] \n"
}
# check whether user had supplied -h or --help . If yes display usage
if [[ ( $# == "--help") || $# == "-h" ]]
then
@jogaco
jogaco / nginxlogs.sh
Created November 2, 2015 12:02
One liner for counting unique IP addresses from nginx rotating logs
ls -t /var/log/nginx/access.log.*.gz | xargs zcat | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 100
@jogaco
jogaco / apache-fakegooglebot
Created October 24, 2015 12:09
Alternative for fail2ban fake gooblebot detection when getting the error ImportError: No module named fail2ban.server.filter
#!/usr/bin/python
# Inspired by https://isc.sans.edu/forums/diary/When+Google+isnt+Google/15968/
#
# Written in Python to reuse built-in Python batteries and not depend on
# presence of host and cut commands
#
import sys
import socket
def process_args(argv):
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"