Skip to content

Instantly share code, notes, and snippets.

@hkarakose
hkarakose / HttpUrlReadAndParseApp
Last active Dec 25, 2015
Read and parse a web page
View HttpUrlReadAndParseApp
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;
View UploadFile.java
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 Jul 24, 2017
JHipster Default Data in SQL format
View data-h2.sql
--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 Aug 9, 2017
Log4j Configuration
View log4j.xml
<?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 / MethodLogger
Last active Aug 9, 2017
Aspect to intercept method executions and log method name, parameter values, duration and return values
View MethodLogger
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;
@hkarakose
hkarakose / .gitlab-ci.yml
Created Aug 23, 2017
A simple Gitlab CI configuration which uses a maven docker image that comes with Java 8 installed
View .gitlab-ci.yml
image: maven:3-jdk-8
build:
#-B: run in batch mode
script: "mvn clean install -B"
@hkarakose
hkarakose / .gitlab-ci.yml
Created Aug 23, 2017
Gitlab CI script which starts a maven image and links it to a mysql service
View .gitlab-ci.yml
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 Sep 21, 2017
Following class print spring.datasource configuration properties in a spring-boot application. This class can be useful if used during application startup.
View ApplicationProperties.java
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 Feb 1, 2018 — forked from ronlobo/countries.sql
Countries sql script
View countries.sql
-- 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 (thomas@tourlourat.com)
@hkarakose
hkarakose / get_dataset.py
Created May 6, 2018 — forked from ardamavi/get_dataset.py
For reading datasets and converting to numpy files.
View get_dataset.py
# Arda Mavi
import os
import numpy as np
from os import listdir
from scipy.misc import imread, imresize
from keras.utils import to_categorical
from sklearn.model_selection import train_test_split
# Settings:
img_size = 64