Skip to content

Instantly share code, notes, and snippets.

Timur milovtim

  • MTVv
  • Saint-Petersburg
View GitHub Profile
@milovtim
milovtim / get_prop_keys.bash
Last active Jan 30, 2019
Grap keys from bunch of .properties files with keys with [a-z _ .]
View get_prop_keys.bash
#!/usr/bin/env bash
# files with prop keys on each line
KEYS_FILE="/path/to/result.list"
# Extract keys to file
awk -F = '/^[a-z_.]+=/ { print $1 }' /some/path/files > "$KEYS_FILE"
# path to some repo
SEARCH_PATH="/path/to/repo"
@milovtim
milovtim / ssh-copy-id.sh
Created Jan 10, 2019
A commands under ssh-copy-id helper script
View ssh-copy-id.sh
printf '%s\n' "$NEW_IDS" | ssh "$@" "
umask 077 ;
mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi"
@milovtim
milovtim / create_logback_appenders.groovy
Last active Dec 7, 2018
LOG_PATH -- env/local var of log files location, FILE_LOG_PATTERN -- env/local val with pattern
View create_logback_appenders.groovy
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>
View curl.md

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
@milovtim
milovtim / pom.xml
Created Jun 14, 2018 — forked from drguildo/pom.xml
Maven Kotlin Example
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
View completable_futures_allOf_example.groovy
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)
View completable-futures.groovy
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 / pom.xml
Created Mar 21, 2018
maven-compiler-plugin-groovy-compilation
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>
@milovtim
milovtim / table.filter.lua
Created Mar 16, 2018 — forked from FGRibreau/table.filter.lua
Lua table.filter (JavaScript Array::filter equivalent)
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
@milovtim
milovtim / SpringContextHierarchy.groovy
Last active Jan 15, 2018
Demonstration on bean definitions inheritanse between parent-child contexts
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
You can’t perform that action at this time.