This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| usage="usage: $(basename "$0") [-h] [-r] [-s] [-t] -n name | |
| options: | |
| -n name Name of JAR (including .jar extension) | |
| -r restart Restart jar once deployed | |
| -t target Set target, for instance demo1 | |
| -s SSH target Set SSH target, for instance -s usr@my_host -t /home/usr/remote/dir/path | |
| -h [help] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private <V> V findMostFrequentItem(final Collection<V> items) | |
| { | |
| return items.stream() | |
| .filter(Objects::nonNull) | |
| .collect(Collectors.groupingBy(Functions.identity(), Collectors.counting())).entrySet().stream() | |
| .max(Comparator.comparing(Entry::getValue)) | |
| .map(Entry::getKey) | |
| .orElse(null); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.util.Arrays; | |
| import javax.servlet.ServletException; | |
| import org.apache.catalina.startup.Tomcat; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; | |
| import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer; | |
| import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // async kotlin collections map | |
| suspend fun <A, B> List<A>.awmap(f: suspend (A) -> B): List<B> { | |
| return map { async { f(it) } } // create async function call | |
| .map { it.await() } // await it on next map call | |
| } | |
| suspend fun <A, B> List<A>.amap(f: suspend (A) -> B): List<Deferred<B>> = map { async { f(it) } } // create async function call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.InputStreamReader; | |
| import java.io.UnsupportedEncodingException; | |
| import java.net.MalformedURLException; | |
| import java.net.URL; | |
| import java.net.URLEncoder; | |
| import javax.annotation.Nonnull; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; | |
| import java.util.stream.Collectors; | |
| import javax.annotation.PostConstruct; | |
| import javax.servlet.FilterChain; | |
| import javax.servlet.ServletException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| TOKEN_URI='http://bla.si:8180/auth/realms/ble/protocol/openid-connect/token' | |
| CLIENT_ID='js-client' | |
| USERNAME='taavci' | |
| PASSWORD='test' | |
| RESULT=`curl --data "grant_type=password&client_id=$CLIENT_ID&username=$USERNAME&password=$PASSWORD" $TOKEN_URI` | |
| TOKEN=`echo $RESULT | sed 's/.*access_token":"//g' | sed 's/".*//g'` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun <T> T.throwIf(predicate: (T) -> Boolean, throwBlock: (T) -> Exception): Unit = if (predicate(this)) throw throwBlock(this) else Unit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.Duration; | |
| import java.util.concurrent.ConcurrentHashMap; | |
| import java.util.concurrent.ConcurrentMap; | |
| public class RateLimitFactory { | |
| private final ConcurrentMap<String, RateLimiter> rateLimiters = new ConcurrentHashMap<>(); | |
| private long capacity; | |
| private Duration window; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| PIDS=$(ps axww -o pid,command | grep -v bash | grep Applications/ | grep -v /bin/sh | grep -v Self\Service | grep -v grep | awk '{print $1}') | |
| for i in ${PIDS} | |
| do | |
| echo "Killing PID $i" | |
| kill -9 $i | |
| done |
OlderNewer