View get-file-column.bash
FILE=''
FILTER_EXPR=''
DELIM=' '
# col num -- 3, change if need another
cat $FILE |grep $FILTER_EXPR|awk -F"$DELIM" '{print $3}'|sort|uniq -c> result.txt
View guava-tree-traversal.groovy
import com.google.common.collect.TreeTraverser
// format (id/parentId)
def data = [
'1/0',
'2/1', '3/1',
'4/2', '5/2', '6/3',
'7/5', '8/5', '9/6'
]
View git-branch-remote-delete.bash
git branch --list -r |
grep -P "SOME_REGEXP" |
while read line;
do
IFS="/" read -r -a arr <<< "$line";
git push origin --delete "${arr[1]}";
done
View jackson_databind_json_append.groovy
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SequenceWriter
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonAppend
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.cfg.MapperConfig
import com.fasterxml.jackson.databind.introspect.AnnotatedClass
View BenManesCaffeine.groovy
import com.github.benmanes.caffeine.cache.CacheLoader
import com.github.benmanes.caffeine.cache.LoadingCache
import com.github.benmanes.caffeine.cache.Caffeine
import com.github.benmanes.caffeine.cache.RemovalCause
static def threadName() {
"${Thread.currentThread().name}}"
}
LoadingCache<Integer, Integer> cache = Caffeine.newBuilder()
View groovySqlCopyData.groovy
import groovy.sql.Sql
import groovy.transform.Canonical
import groovy.transform.Field
Sql casinoDb = Sql.newInstance('jdbc:oracle:thin:@host1:1521/testdb1', 'uname', 'passwd')
Sql ewDb = Sql.newInstance('jdbc:oracle:thin:@host2:1521/testdb' , 'uname', 'passwd')
def sourceDataSql = new File('/some/file/path.sql').text
@Canonical
View UniqueByPojoField.java
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.google.common.collect.Maps;
public class UniqueByPojoField {
View TreeVisitor.groovy
package com.panbet.tree
import groovy.transform.ToString
import spock.lang.Shared
import spock.lang.Specification
/**
* Simple example of deep-first and breath-first tree traversal
* Sample tree
* <pre>
View FSMonTest.groovy
package com.panbet.tree
import org.apache.commons.io.IOCase
import org.apache.commons.io.monitor.FileAlterationListener
import org.apache.commons.io.monitor.FileAlterationMonitor
import org.apache.commons.io.monitor.FileAlterationObserver
import static org.apache.commons.io.filefilter.FileFilterUtils.*
View logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds" debug="true">
<property name="FILE_LOG_PATTERN"
value="%d{dd/MM HH:mm:ss:SS} %level [%thread] %logger{10} [%file:%line] %msg%n"/>
<property name="LOG_PATH"
value="#[[$logPrefix$]]#" />
<!-- APPLICATION LOGGING-->