Skip to content

Instantly share code, notes, and snippets.

View michalmela's full-sized avatar
🍈

Michał Mela michalmela

🍈
View GitHub Profile
@michalmela
michalmela / az-k8s-tools.adoc
Last active February 20, 2020 13:02
[az / k8s tools] "awesome" set of tools for kubernetes and azure
import java.util.EnumSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.IntStream;
import java.util.stream.Stream;
@michalmela
michalmela / jg.groovy
Last active January 31, 2020 09:05
[jq] #tools
// groovier jq
// example:
// groovy ./jg.groovy "_.collect { it.entrySet().findAll { it.value == null }*.key }.flatten().unique().sort()" ./example.json
// – lists all the properties that are ever null in any of the elements of the root array
@Grab('info.picocli:picocli:2.0.3')
@picocli.groovy.PicocliScript
import groovy.transform.Field
@Grab('info.picocli:picocli:2.0.3')
@picocli.groovy.PicocliScript
@michalmela
michalmela / TypesafeConfigPropertySourceFactory.java
Last active September 15, 2023 14:27
[hocon-spring] A set of examples of using HOCON / TypesafeConfig (the latter being the more important part, with the former being just one of the optional formats, but HOCON sounds so much better than the mouthful TypesafeConfig) outside of their typical use cases
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
import java.io.IOException;
import java.util.Map;
@michalmela
michalmela / webscraping.groovy
Last active January 31, 2020 09:06
[groovy scraping] Web scraping with groovy & tagsoup
@Grapes( @Grab('org.ccil.cowan.tagsoup:tagsoup:1.2') )
def PARSER = new XmlSlurper(new org.ccil.cowan.tagsoup.Parser() )
(0..13).each {
it -> new URL("https://www.diki.pl/slownik-angielskiego/?q=c%3Aslownik-terminow-prawnicznych&categoryPage=${it*100}").withReader {
reader ->
def document = PARSER.parse(reader)
document.'**'.findAll{ it['@class'] == 'fentry'}.each {
fentry ->
println (fentry.toString().replaceAll('...znacze.?.?.?','').replaceAll('\n','').replaceAll(' +',' '))
@michalmela
michalmela / I18nRequestMappingHandlerMapping.java
Last active January 31, 2020 09:07
[spring i18n uris] I18nRequestMappingHandlerMapping -- a Spring Framework HandlerMapping which supports translation of @RequestMapping values, so that you can have multiple, localized paths to a single controller based on one annotation value and easily add further translations to your mappings without going through all the @RequestMapping value…
package com.blogspot.jmelon.si18nrmhmt.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.condition.*;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
/**
* A {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping} subclass which makes it
* possible to translate a mapped {@link org.springframework.stereotype.Controller Controller}'s {@link