Skip to content

Instantly share code, notes, and snippets.

@zzzfree
zzzfree / HttpClient.groovy
Created September 24, 2013 01:20
HttpClient.groovy
package com.mzeng.gzbus
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@zzzfree
zzzfree / log4j2.xml
Created September 23, 2013 14:04
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<RollingFile name="RollingFile" fileName="logs/app.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
@zzzfree
zzzfree / sshTunnel.groovy
Last active December 27, 2018 12:23
ssh tunnel with groovy
import com.jcraft.jsch.JSch
import com.jcraft.jsch.Session
import com.jcraft.jsch.UserInfo
import com.jcraft.jsch.Channel
import com.jcraft.jsch.ChannelExec
def sshHost = '10.1.2.132'
def sshUser = 'root'
def sshPass = '******'
def sshPort = 22
//http://logging.apache.org/log4j/2.0/manual/configuration.html#ConfigurationSyntax
import org.apache.logging.log4j.Logger;
static Logger logger = LogManager.getLogger(Bar.class.getName());
logger.error("Did it again!");
@zzzfree
zzzfree / gist:5134912
Created March 11, 2013 15:11
Directory Watcher Groovy
package com.wz.service.impl
import com.wz.service.IConfigService
import com.wz.service.IFileService
import com.wz.service.IMonitorService
import com.wz.service.ITagService
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.WatchEvent;
@zzzfree
zzzfree / gist:5126903
Created March 10, 2013 02:55
Java Write Image File
BufferedImage tar = _resize(f,s)
ImageIO.write(tar, "jpg", new File(fileName));
@zzzfree
zzzfree / gist:5114466
Created March 8, 2013 05:46
reflect groovy
class ReflectTest {
def name
def height
def add(){
println "add"
}
def add(a){
@zzzfree
zzzfree / gist:5113873
Created March 8, 2013 02:52
Lucene search page
import org.apache.lucene.analysis.Analyzer
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.index.IndexReader
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.queryparser.classic.QueryParser
import org.apache.lucene.search.IndexSearcher
import org.apache.lucene.search.Query
import org.apache.lucene.search.TopDocs
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
@zzzfree
zzzfree / gist:5113763
Last active December 14, 2015 16:18
Lucene Search
// http://www.cnblogs.com/lcuzhanglei/archive/2012/08/01/2618381.html
// 对于要排序的字段,在索引的时候可以Field.Index.NOT_ANALYZED
import org.apache.lucene.analysis.Analyzer
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.index.IndexReader
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.queryparser.classic.QueryParser
import org.apache.lucene.search.IndexSearcher
import org.apache.lucene.search.Query
@zzzfree
zzzfree / LuceneAdd.groovy
Last active December 14, 2015 16:18
Lucene Add
import org.apache.lucene.analysis.Analyzer
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.document.Document
import org.apache.lucene.document.Field
import org.apache.lucene.document.LongField
import org.apache.lucene.document.StringField
import org.apache.lucene.document.TextField
import org.apache.lucene.index.IndexWriter
import org.apache.lucene.index.IndexWriterConfig
import org.apache.lucene.index.Term