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 / Employee.java
Created February 14, 2024 09:15 — forked from mefernandez/Employee.java
Spring Data's Page and @JSONVIEW solution
@Entity
public class Employee {
@Id
@GeneratedValue
private Long id;
@JsonView(SummaryView.class)
private String name;
@milovtim
milovtim / SchemaFieldsTraverseTool.java
Last active January 16, 2024 06:50
Parse OpenAPI schema and print dot.separated field hierarchy of single schema
import java.util.*;
import java.util.stream.Collectors;
import io.swagger.v3.core.util.RefUtils;
import io.swagger.v3.oas.models.media.JsonSchema;
import io.swagger.v3.oas.models.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.jooq.lambda.Seq;
import org.jooq.lambda.tuple.Tuple;
@milovtim
milovtim / Features.md
Created December 15, 2023 10:11
OpenAPI tweaks

Enums

Standart enums

PetTypes:
  type: string
  description: What animal might be a pet
  enum:
    - cat
    - dog
 - tourtile
@milovtim
milovtim / fix-previous-maven-downloads-failed.sh
Created October 28, 2022 13:50
Maven caches all failed download attempts. After you fixed issues (it's often ssl certificates problems) you need to drop old data about failures
find ~/.m2 -name "*.lastUpdated" \
-exec grep -q "Could not transfer" {} \; \
-print \
-exec rm {} \;
@milovtim
milovtim / allNoneAnyInteroperability.kt
Created September 21, 2022 12:40
How to represent collection boolean aggregating functions one into another
fun List<Int>.allNonZero() = all { it != 0 }
fun List<Int>.allNonZero1() = none { it == 0 }
fun List<Int>.allNonZero2() = !any { it == 0 }
fun List<Int>.containsZero() = any { it == 0 }
fun List<Int>.containsZero1() = !all { it != 0 }
fun List<Int>.containsZero2() = !none { it == 0 }
fun main(args: Array<String>) {
val list1 = listOf(1, 2, 3)
@milovtim
milovtim / app.java
Created May 20, 2021 11:55 — forked from mobleyc/app.java
Loading resource bundles in Java from property files outside of classpath, with different file extensions.
package com.cpm;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Locale;
import java.util.PropertyResourceBundle;
@milovtim
milovtim / xfwm4-reset-hotkeys-for-intellij.sh
Last active September 29, 2020 11:12
Remove key bindings that conflicts with (shadows) intelliJ keymaps
#!/usr/bin/env bash
XCONF_PROP="xfconf-query -c xfce4-keyboard-shortcuts -p"
RST="-r"
while IFS= read -r line; do
eval "$XCONF_PROP" "\"$line\"" "$RST";
done <<'EOF'
/xfwm4/custom/<Alt>Insert
/xfwm4/custom/<Alt>Delete
@milovtim
milovtim / get_prop_keys.bash
Last active January 30, 2019 10:11
Grap keys from bunch of .properties files with keys with [a-z _ .]
#!/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 January 10, 2019 10:50
A commands under ssh-copy-id helper script
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 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>