Skip to content

Instantly share code, notes, and snippets.

View SlyDen's full-sized avatar

Denys Slipetskyy SlyDen

  • Lviv, Ukraine
View GitHub Profile
@SlyDen
SlyDen / create-java-dirs.gradle
Last active December 23, 2015 17:29
Task to create standard Java application's dir tree with .gitkeep files inside.
task "create-dirs" << {
sourceSets*.java.srcDirs*.each {
it.mkdirs()
(new File("${it}/.gitkeep")).createNewFile()
}
sourceSets*.resources.srcDirs*.each {
it.mkdirs()
(new File("${it}/.gitkeep")).createNewFile()
}
@SlyDen
SlyDen / word_html_filter.js
Created September 24, 2013 07:27
http://habrahabr.ru/post/194848/ Большинство используемых регулярок были подсмотрены у TinyMCE. Как определить, есть ли в строке html-код вставленный из Ворда: if (/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test( content )) { ... } Функция чистки кода (в функцию передается jquery объект редактора):
(function($) {
$.fn.msword_html_filter = function(options) {
var settings = $.extend( {}, options);
function word_filter(editor){
var content = editor.html();
// Word comments like conditional comments etc
content = content.replace(/<!--[\s\S]+?-->/gi, '');
@SlyDen
SlyDen / gist:7943466
Created December 13, 2013 12:20
simple SQL escaper for java
/**
* Copyright (C) 2011 JTalks.org Team
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
@SlyDen
SlyDen / spring-boot-props
Last active January 3, 2016 02:49
how to find some properties for Spring Boot
package org.springframework.boot.autoconfigure.orm.jpa;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.ejb.HibernateEntityManager;
import org.springframework.beans.factory.BeanClassLoaderAware;
@SlyDen
SlyDen / SampleSecureApplicationTests.java
Last active January 3, 2016 10:59
Spring Boot Web app HTTP tests example spring-boot-samples/spring-boot-sample-web-secure/src/test/java/sample/ops/ui/SampleSecureApplicationTests.java in https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@SlyDen
SlyDen / Application.java
Created March 7, 2014 09:41
Sample of Spring Boot config with custom setting for embedded Tomcat And OAuth ... imports are skiped. https://github.com/joshlong/the-spring-rest-stack/blob/master/code/web/oauth/src/main/java/com/jl/crm/web/Application.java
@ComponentScan
@Import(ServiceConfiguration.class)
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
private static Class<Application> applicationClass = Application.class;
public static void main(String[] args) {
SpringApplication.run(applicationClass);
}
$ ->
token = $('meta[name="csrf-token"]').attr('content')
$.ajaxPrefilter (options, originalOptions, xhr) ->
xhr.setRequestHeader('X-CSRF-Token', token)
$("#someid").off("click").on("click",function(){...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.greglturnquist.embeddablesdr.Application</start-class>
<java.version>1.7</java.version>
</properties>
package test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-test.xml" })