Skip to content

Instantly share code, notes, and snippets.

View milovtim's full-sized avatar

Timur milovtim

  • MTVv
  • Saint-Petersburg
View GitHub Profile
@milovtim
milovtim / create_logback_appenders.groovy
Last active December 7, 2018 10:15
LOG_PATH -- env/local var of log files location, FILE_LOG_PATTERN -- env/local val with pattern
def tmpl = {
"""
<appender name="${it.toUpperCase()}_FILE"
additivity="false"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${LOG_PATH}/${it.toLowerCase()}.log</file>
<encoder><pattern>\${FILE_LOG_PATTERN}</pattern></encoder>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${LOG_PATH}/old/${it.toLowerCase()}_%d{yyyy-MM-dd, aux}/${it.toLowerCase()}.%d{yyyy-MM-dd-HH}.gz</fileNamePattern>
@milovtim
milovtim / curl.md
Last active November 14, 2018 12:59

curl often used options

  • -X {method} where method is {GET,POST,HEAD,etc.} (Default: GET)
  • -v verbose mode
  • -o to_file/-O save output to_file or use server-provided filename
    • -J use filename from header
  • -L follow Location header when 3xx code returns
  • -#/--progress-bar use simple progress bar (single-line) instead of default download info
  • -s silent mode
interface DemoInterface {
HelloMsg sayHelloImpl(AddresseeRequest request);
@RequestMapping(value = "/hello")
default HelloMsg sayHello(@RequestBody AddresseeRequest request) {
return sayHelloImpl(request);
}
}
@RestController
@milovtim
milovtim / bash_aliases.sh
Last active July 11, 2018 07:37
milovtim bash aliases
##### 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."'
#
import groovy.transform.Canonical
import java.util.concurrent.CompletableFuture
import java.util.function.Function
import java.util.function.Supplier
final long serviceExecutionTime = 1000
def rand = new Random()
def initVal = rand.nextInt(100)
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import java.util.function.Supplier
Supplier treeItemSupp = { sleep(50); '`treeItem`' }
Supplier eventItemSupp = { sleep(100); ' `event`'; new RuntimeException('bam!') }
Supplier l10nItemSupp(String treeItem) { return {sleep(200); " `l10n($treeItem)`"} as Supplier }
CompletableFuture.supplyAsync(treeItemSupp)
.thenCompose({ str ->
@milovtim
milovtim / table.filter.lua
Created March 16, 2018 11:43 — forked from FGRibreau/table.filter.lua
Lua table.filter (JavaScript Array::filter equivalent)
-- 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
@milovtim
milovtim / SpringContextHierarchy.groovy
Last active January 15, 2018 14:46
Demonstration on bean definitions inheritanse between parent-child contexts
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
@milovtim
milovtim / spring-integration-sample.groovy
Created November 29, 2017 10:55
Simple context to check spring-integration components
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"
@milovtim
milovtim / get-file-column.bash
Created November 10, 2017 09:55
Fetch columnd from (log) file. This example was used for tomcat access log
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