Skip to content

Instantly share code, notes, and snippets.

View jogaco's full-sized avatar
🎯
Focusing

J. Garcia jogaco

🎯
Focusing
View GitHub Profile
class ArticleImageUploader < ImageUploader
process :fix_exif_rotation
process :strip
process :convert => 'jpg'
process :quality => 85 # Percentage from 0 - 100
version :gallery_thumb do
process :resize_to_fill => Settings.images.article_images.processing.gallery_thumb #44x44
end
@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):
@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 / 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
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 / 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 / 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 / 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 / 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 / pom.xml
Last active May 21, 2017 17:30
Spring Boot Tutorial: Adding dbunit-maven-plugin
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<dataTypeFactoryName>${dbunit.dataTypeFactoryName}</dataTypeFactoryName>
<driver>${jdbc.driverClassName}</driver>
<username>${jdbc.username}</username>
<password>${jdbc.password}</password>