Skip to content

Instantly share code, notes, and snippets.

@hkarakose
hkarakose / HttpUrlReadAndParseApp
Last active December 25, 2015 05:09
Read and parse a web page
package reader;
import bilgiturk.commons.ParserFactory;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.htmlparser.Parser;
import org.htmlparser.filters.CssSelectorNodeFilter;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
@hkarakose
hkarakose / ListFilesAndFolderInBucket.java
Last active June 22, 2018 20:31
Display list of files/folders in a Google Cloud Storage(GSC) bucket
import com.google.cloud.Page;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.Storage;
import com.labsite.repository.StorageFactory;
import java.util.Iterator;
/**
* User: Halil Karakose
* Date: 31/01/17
@hkarakose
hkarakose / MethodLogger
Last active August 9, 2017 16:31
Aspect to intercept method executions and log method name, parameter values, duration and return values
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
public static boolean upload(String url, String username, String password, File file) {
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect(url);
client.login(username, password);
fis = new FileInputStream(file);
@hkarakose
hkarakose / data-h2.sql
Created July 24, 2017 08:38
JHipster Default Data in SQL format
--USER TABLE
INSERT INTO JHI_USER(ID, LOGIN, PASSWORD_HASH, FIRST_NAME, LAST_NAME, EMAIL, ACTIVATED, LANG_KEY, CREATED_BY, LAST_MODIFIED_BY, CREATED_DATE)
VALUES(1, 'system', '$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG', 'System', 'System', 'system@localhost', true, 'EN', 'system', 'system', SYSDATE);
INSERT INTO JHI_USER(ID, LOGIN, PASSWORD_HASH, FIRST_NAME, LAST_NAME, EMAIL, ACTIVATED, LANG_KEY, CREATED_BY, LAST_MODIFIED_BY, CREATED_DATE)
VALUES(2, 'anonymoususer', '$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO', 'Anonymous', 'User', 'anonymous@localhost', true, 'EN', 'system', 'system', SYSDATE);
INSERT INTO JHI_USER(ID, LOGIN, PASSWORD_HASH, FIRST_NAME, LAST_NAME, EMAIL, ACTIVATED, LANG_KEY, CREATED_BY, LAST_MODIFIED_BY, CREATED_DATE)
VALUES(3, 'admin', '$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC', 'Administrator', 'Administrator', 'admin@localhost', true, 'EN', 'system', 'system', SYSDATE);
@hkarakose
hkarakose / log4j.xml
Created August 9, 2017 16:14
Log4j Configuration
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
<param name="File" value="/var/log/tomcat7/chat.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="INFO"/>
<param name="DatePattern" value="'.'yyyy-MM-dd-a"/>
<layout class="org.apache.log4j.PatternLayout">
@hkarakose
hkarakose / .gitlab-ci.yml
Created August 23, 2017 07:41
A simple Gitlab CI configuration which uses a maven docker image that comes with Java 8 installed
image: maven:3-jdk-8
build:
#-B: run in batch mode
script: "mvn clean install -B"
@hkarakose
hkarakose / .gitlab-ci.yml
Created August 23, 2017 07:50
Gitlab CI script which starts a maven image and links it to a mysql service
image: maven:3-jdk-8
services:
# mysql hostname is 'mysql'. You should configure your db configuration so that it connects to 'mysql' host.
- mysql:latest
variables:
# Configure mysql environment variables (https://hub.docker.com/r/_/mysql/)
MYSQL_DATABASE: REPLACE_WITH_YOUR_DB_NAME
MYSQL_ROOT_PASSWORD: REPLACE_WITH_YOUR_ROOT_PASSWORD
@hkarakose
hkarakose / ApplicationProperties.java
Created September 21, 2017 16:42
Following class print spring.datasource configuration properties in a spring-boot application. This class can be useful if used during application startup.
package com.kodfarki.scheduler;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* User: Halil Karakose
* Date: 21/09/2017
* Time: 19:31
*/
@hkarakose
hkarakose / countries.sql
Created February 1, 2018 20:35 — forked from ronlobo/countries.sql
Countries sql script
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Serveur: localhost
-- Généré le : Jeu 04 Mars 2010 à 12:12
-- Version du serveur: 5.1.36
-- Version de PHP: 5.3.0
-- Autor : Thomas Tourlourat ([email protected])