View bash_aliases.sh
##### ea - alias for editing aliases
#
#When setting up a new aliases file, or having creating a new file.. About every time after editing an aliases file, I source it. This alias makes editing alias a
#bit easier and they are useful right away. Note if the source failed, it will not echo "aliases sourced".
#
#Sub in gedit for your favorite editor, or alter for ksh, sh, etc.
#
alias ea='gedit ~/.bash_aliases; source ~/.bash_aliases && source $HOME/.bash_aliases && echo "aliases sourced --ok."'
#
View pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>false</verbose>
</configuration>
View table.filter.lua
-- table.filter({"a", "b", "c", "d"}, function(o, k, i) return o >= "c" end) --> {"c","d"}
--
-- @FGRibreau - Francois-Guillaume Ribreau
-- @Redsmin - A full-feature client for Redis http://redsmin.com
table.filter = function(t, filterIter)
local out = {}
for k, v in pairs(t) do
if filterIter(v, k, t) then out[k] = v end
end
View SpringContextHierarchy.groovy
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.support.GenericGroovyApplicationContext
interface ServiceInParent {
String invokeParent()
}
class ChildService {
ServiceInParent serviceInParent
View spring-integration-sample.groovy
import org.springframework.context.support.GenericXmlApplicationContext
import org.springframework.core.io.ByteArrayResource
import org.springframework.integration.support.MessageBuilder
import org.springframework.messaging.MessageChannel
def xml = '''<?xml version="1.0" encoding="UTF-8"?>
<bean:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bean="http://www.springframework.org/schema/beans"
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()